[R] Using functions/loops for repetitive commands
David Winsemius
dwinsemius at comcast.net
Thu May 5 20:01:33 CEST 2011
On May 5, 2011, at 1:45 PM, dereksloan wrote:
> 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.
I don't generally answer questions that support shotgun approaches to
manufacturing p-values for fear of encouraging unprincipled data-
ming ... unless it is clear that the questioner understands what he
are doing from a statistical point of view. So my apologies. I
probably shouldn't have even posted in this case. I misunderstood the
question and thought it was just a quick syntactic fix. I now
understand it to be more involved and really demands more care and
respect than I was giving it.
>
> 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
--
David Winsemius, MD
West Hartford, CT
More information about the R-help
mailing list