[R] Using functions/loops for repetitive commands

2011-05-05 Thread dereksloan
I still need to do some repetitive statistical analysis on some outcomes from a dataset. Take the following as an example; id sex hiv age famsize bmi resprate 1 M Pos 23 2 16 15 2 F Neg 24 5 18

Re: [R] Using functions/loops for repetitive commands

2011-05-05 Thread dereksloan
Your code may be untested but it works - also helping me slowly to start understanding how to write functions. Thank you. However I still have difficulty. I also have some categorical variables to analyse by age hiv status - i.e. my dataset expands to (for example); id sex hiv age

Re: [R] Using functions/loops for repetitive commands

2011-05-05 Thread dereksloan
Thanks David, I did notice that and I got his code to work using wilcox.test for the continuous variables. The problem is that when I tried to alter the code to do chisq.test on my categorical variables there is something wrong with the syntax and I don't know what. Derek -- View this message

Re: [R] Using functions/loops for repetitive commands

2011-05-05 Thread dereksloan
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

[R] Generating summary statistics and simple statistical analysis from my data-set: how can I automate the analysis?

2011-05-03 Thread dereksloan
I am fairly new to R and have a (for me) slightly complicated set of data to analyse. It contains several continuous and categorical variables for a group of individuals – e.g; ID Sex Age Familysize Phone Education 1 M 23 3 Yes

[R] Several factors same levels

2011-04-19 Thread dereksloan
This is probably very simple but I'm new to R so apologies for being stupid. I have some data with No coded as 0 and yes coded as 1. e.g. id sex alcohol smoker 1 M 01 2 F 10 3 M 00 I realise I can covert the numerical variable back to a factor by