[R] How to apply two parameter function in data frame
jon waterhouse
jonwaterhouse at gov.nl.ca
Tue Mar 6 21:15:53 CET 2012
I know this is something simple that I cannot do because I do not yet "think"
in R.
I have a data frame has a variable participation (a factor), and several
other factors.
I want a chisq test (no contingency tables) for participation vs all of the
other factors.
In SPSS I would do:
CROSSTABS
/TABLES= (my other factors) BY participation
/FORMAT=NOTABLES
/STATISTICS=CHISQ
/COUNT ROUND CELL.
In R I have tried something like:
mapply(chisq.test,participation,surv3[,names(surv3) %in% c('q10','q44')])
which should be effectively the same as
chisq.test(participation,q10)
chisq.test(participation,q44)
except maybe I could store the results better....
but I get told that x and y are not the same length, and in this case,
length() of the y argument is 2, which yes, is not the number of rows in the
data frame.
I'm not sure that it is mapply, rather than lapply that I want
Thanks,
Jon
--
View this message in context: http://r.789695.n4.nabble.com/How-to-apply-two-parameter-function-in-data-frame-tp4451211p4451211.html
Sent from the R help mailing list archive at Nabble.com.
More information about the R-help
mailing list