Thanks for the explanation. And tip... this was a quick a dirty code so didn't really think about naming something that is already a function in R. Data was generic - just a bunch of columns with numbers so didn't bother including that as I know that wasn't the problem. Same goes with replying - automatically went to reply, will remember to reply-all.
On Wed, May 21, 2014 at 3:11 PM, Sarah Goslee <sarah.gos...@gmail.com> wrote: > That would be because col is a function in base R, and thus a poor > choice of names for user objects. Nonetheless, it worked when I ran > it, but you didn't provide reproducible example so who knows. > > R> set.seed(1) > R> x <- data.frame(matrix(runif(150), ncol=10)) > R> # col is a function, so not a good name > R> col <- colMeans(x) > R> mean(col) > [1] 0.5119 > > It's polite to include the list on your reply. > > Sarah > > On Wed, May 21, 2014 at 2:50 PM, Kate Ignatius <kate.ignat...@gmail.com> > wrote: >> That didn't work: gave me the error = >> >> [1] NA >> Warning message: >> In mean.default(col) : argument is not numeric or logical: returning NA >> >> But writing it like: mean(colMeans(x, na.rm = TRUE, dims = 1)), worked >> >> Thanks! >> >> On Wed, May 21, 2014 at 2:31 PM, Sarah Goslee <sarah.gos...@gmail.com> wrote: >>> Is >>> >>> mean(col) >>> >>> not what you're looking for? >>> >>> Sarah >>> >>> On Wed, May 21, 2014 at 2:26 PM, Kate Ignatius <kate.ignat...@gmail.com> >>> wrote: >>>> Hi All, >>>> >>>> I've successfully gotten out the colMeans for 60 columns using: >>>> >>>> col <- colMeans(x, na.rm = TRUE, dims = 1) >>>> >>>> My next question is: is there a way of getting a mean of all the >>>> column means (ie a mean of a mean)? >>>> >>>> Thanks! >>>> > > -- > Sarah Goslee > http://www.functionaldiversity.org ______________________________________________ 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.