Sunday, 15 July 2012

unexpected symbol in R please see the code -


I was trying to write a function to parse and merge some data. But R throws an unexpected symbol error exception. I have tried different ways to solve this issue, still does not work. help please.

See the code

  $ aggall = function (df, grp) {numcols = sapply (df, class)% c% c ('integer', 'numeric') The result = total (df [, numcols], df [grp], mean) calculation = as.data.frame (table (df [grp]) name (count) [1] = grp merge (calculation, result error: " Ungrouped symbol {aggall = function (go, grp) in {numcols = sapply (go, class)% c in% c ('integer', 'As a result, your physical work is in a physical line.) Therefore, when  R  tries to parse it, this is not a method when a line ends and the next one starts  

To fix this, either use separate lines or add a semicolon between them.


Alternatively, you can see the FormatR package can do for you! (Very Awful Package): install.packages ("formatR") library (formatR) tidy.source (" Mysource.r ", reindent.space = 5) aggall = function (df, grp) {numcols = sapply (df, class)% in% C (" integer "," numeric ") results = total (df [, numcols] , Df [grp], mean) calculation = as.data.frame (table (df [grp]) name (count) [1] = grp merge (calculation, result, sort = FALSE)}

No comments:

Post a Comment