I am trying to get the means of each participants avg saccade amplitude as a function of the group they were in (designated by "shape_"), but there are missing values in the dataset....this is what i tried... with(data055,tapply(AVERAGE_SACCADE_AMPLITUDE,shape_,mean)) i get an error saying the argument is not numerical or logical next i try...> 055 <- tapply(data055$AVERAGE_SACCADE_AMPLITUDE,+ data055$shape_,mean, na.rm =TRUE) still nothing.... help? thanks! -- View this message in context: http://r.789695.n4.nabble.com/apply-with-missing-values-tp4653889.html Sent from the R help mailing list archive at Nabble.com.
A bit of data might be useful. Make a small example and post the data with dput(). On 24.12.2012, at 20:21, jenna wrote:> I am trying to get the means of each participants avg saccade amplitude as a > function of the group they were in (designated by "shape_"), but there are > missing values in the dataset....this is what i tried... > > with(data055,tapply(AVERAGE_SACCADE_AMPLITUDE,shape_,mean)) > i get an error saying the argument is not numerical or logical > > next i try... > >> 055 <- tapply(data055$AVERAGE_SACCADE_AMPLITUDE, > + data055$shape_,mean, na.rm =TRUE) > > still nothing.... > > help? thanks! > > > > -- > View this message in context: http://r.789695.n4.nabble.com/apply-with-missing-values-tp4653889.html > Sent from the R help mailing list archive at Nabble.com. > > ______________________________________________ > R-help at 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.
On Dec 24, 2012, at 11:21 AM, jenna wrote:> I am trying to get the means of each participants avg saccade > amplitude as a > function of the group they were in (designated by "shape_"), but > there are > missing values in the dataset....this is what i tried... > > with(data055,tapply(AVERAGE_SACCADE_AMPLITUDE,shape_,mean)) > i get an error saying the argument is not numerical or logicalThe error message appears informative (and would NOT be expected to be solved by adding na.rm=TRUE). Your construction of the data055 dataframe was flawed in some way. You have not shown how it was done nor given dput(head(data055)) which would have provided a basis for further assessment. Based on past experience my guess is that there was a character value in the column of data you thought was numeric during a read.* operation and is now a factor.> > next i try... > >> 055 <- tapply(data055$AVERAGE_SACCADE_AMPLITUDE, > + data055$shape_,mean, na.rm =TRUE) > > still nothing....-- David Winsemius, MD Alameda, CA, USA