You can use aggregate: aggregate(data[,c("ozone", "solar.r", "wind", "temp")], list(month=data$month), mean)
On 12/02/2008, [Ricardo Rodriguez] Your XEN ICT Team <[EMAIL PROTECTED]> wrote: > Hi all, > > We are facing a problem while introducing ourselves to Reshape package > use. Melt seems to work fine, but cast fails when we use mean as > fun.aggregate. As you see here, length and sum work fine, but mean > throws this same error whatever dataset we use. > > > cast(aqm, month ~ variable, length) > month ozone solar.r wind temp > 1 5 26 27 31 31 > 2 6 9 30 30 30 > 3 7 26 31 31 31 > 4 8 26 28 31 31 > 5 9 29 30 30 30 > > cast(aqm, month ~ variable, sum) > month ozone solar.r wind temp > 1 5 614 4895 360.3 2032 > 2 6 265 5705 308.0 2373 > 3 7 1537 6711 277.2 2601 > 4 8 1559 4812 272.6 2603 > 5 9 912 5023 305.4 2307 > > cast(aqm, month ~ variable, mean) > Error in get(as.character(FUN), mode = "function", envir = envir) : > variable "fun" of mode "function" was not found > > > > > Our environment: > > > version > _ > platform i386-apple-darwin8.10.1 > arch i386 > os darwin8.10.1 > system i386, darwin8.10.1 > status > major 2 > minor 6.2 > year 2008 > month 02 > day 08 > svn rev 44383 > language R > version.string R version 2.6.2 (2008-02-08) > > > > installed.packages() > > reshape "reshape" > "/Library/Frameworks/R.framework/Resources/library" "0.8.0" > NA NA > > > Please, could you help use to work out this issue? Thanks! > > -- > Ricardo Rodríguez > Your XEN ICT Team > > ______________________________________________ > R-help@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. > -- Henrique Dallazuanna Curitiba-Paraná-Brasil 25° 25' 40" S 49° 16' 22" O ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.