[R] mapply on multiple data frames
Webb,Elizabeth E
webbe at ufl.edu
Tue Jun 11 08:07:10 CEST 2013
Hi all-
I am wondering about using the mapply function to multiple data frames. Specifically, I would like to do a t-test on a subset of multiple data frames. All data frames have the same structure.
Here is my code so far:
f<-function(x,y) {
test<-t.test(x$col1[x$col3=="num",],v$col2[x$col3=="num",],paired=T,alternative="greater")
out<-test$p.value
return(out)
}
all_nums<-list(num1,num2,num3,num4)
all_dfs<-list(df1,df2,df3,df4)
mapply(f,all_dfs,all_nums)
This tells me that $ operator is invalid for atomic vectors. I have tried shifting to notation using [ ,] to denote columns, but that gives me this error: incorrect number of dimensions.
Thank you in advance,
Elizabeth
More information about the R-help
mailing list