[R] Using functions/loops for repetitive commands

dereksloan djsloan at liv.ac.uk
Thu May 5 19:45:01 CEST 2011


Thanks a lot,

I understand what you say but I'm having problems - maybe with the syntax or
the specific command.

You are right - I have a dataframe to store the data and want to automate
the analysis.

i.e. I want do a chisq.test with to know if alcohol intake (Y/N) differs
between sexes, then if smoking (Y/N) differs between sexes, then if alcohol
intake or smoking differ by hiv status.

The command within my data frame for each individual comparison is e.g.

chisq.test(alcohol,sex)... then repeat it for all combination of variables.

but using lapply I'm still unsure how to design the loop.

I'll keep trying - let me know if you have more ideas.

Derek


--
View this message in context: http://r.789695.n4.nabble.com/Using-functions-loops-for-repetitive-commands-tp3498006p3499001.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list