Re: [R] Mutliple sets of data in one dataset....Need a loop?

2010-01-22 Thread Mario Valle
Great example Glen! I want to add simply a small thing that could be useful to someone. Suppose in your last step you want to change the line color for each chart. Using a for loop it is simple to use the integer index to access the df.lst elements and set the color: for(i in

Re: [R] Mutliple sets of data in one dataset....Need a loop?

2010-01-22 Thread Glen Sargeant
Thank you, Mario. Biostudent asked how one could perform repetitive tasks, e.g., plotting, with subsets of data. I originally provided a flexible example based on lapply. Mario suggested a variation that permits flexible control of options. This reply shows how Mario's objective and naming of

Re: [R] Mutliple sets of data in one dataset....Need a loop?

2010-01-21 Thread BioStudent
Hi Thanks for all your help Its a little difficult to follow those examples as all seem so different and its hard to see how I do what I want to my data from the help files but i'll try... -- View this message in context:

Re: [R] Mutliple sets of data in one dataset....Need a loop?

2010-01-21 Thread Matthew Dowle
but I have thousands of results so it would be really hand to find away of doing this quickly its a little difficult to follow those examples Given your data in data.frame DF, maybe add the following to your list to investigate : dat = data.table(DF) dat[, cor(Score1,Score2),

[R] Mutliple sets of data in one dataset....Need a loop?

2010-01-20 Thread BioStudent
Hi I'm hoping someone can help me I am a relative newbie to R. I have data that is in a similar format to this... Experiment Score1 Score2 X -0.85 -0.02 X -1.21 -0.02 X 1.05 0.09 Y -1.12 -0.07 Y -0.27 -0.07 Y -0.93 -0.08 Z 1.1 -0.03 Z 2.4 0.09 Z -1.0 0.09 Now I can easily have a look at the

Re: [R] Mutliple sets of data in one dataset....Need a loop?

2010-01-20 Thread David Winsemius
On Jan 20, 2010, at 11:07 AM, BioStudent wrote: Hi I'm hoping someone can help me I am a relative newbie to R. I have data that is in a similar format to this... Experiment Score1 Score2 X -0.85 -0.02 X -1.21 -0.02 X 1.05 0.09 Y -1.12 -0.07 Y -0.27 -0.07 Y -0.93 -0.08 Z 1.1 -0.03 Z 2.4

Re: [R] Mutliple sets of data in one dataset....Need a loop?

2010-01-20 Thread David Freedman
You'll probably want to look at the 'by' function d=data.frame(sex=rep(1:2,50),x=rnorm(100)) d$y=d$x+rnorm(100) head(d) cor(d) by(d[,-1],d['sex'],function(df)cor(df)) You might also want to look at the doBy package -- View this message in context:

Re: [R] Mutliple sets of data in one dataset....Need a loop?

2010-01-20 Thread Glen Sargeant
One way to plot subsets of data identified by a grouping variable is to use lapply() on a list of subsets. The approach is worth mentioning because similar tactics are useful for many problems. #List of unique values for grouping variable #that is not necessarily a factor names -