Re: [R] Performing operations only on selected data

2012-11-26 Thread arun
00 3.000 4.000 4.000 #[15] 4.000 4.000 A.K. - Original Message - From: Jeff Newmiller To: Marcel Curlin ; r-help@r-project.org Cc: Sent: Monday, November 26, 2012 1:23 AM Subject: Re: [R] Performing operations only on selected data a) Please read the posting

Re: [R] Performing operations only on selected data

2012-11-25 Thread Jeff Newmiller
a) Please read the posting guide. This mailing list is not Nabble, and you are requested to post in plain text and include context from previous messages in the thread. b) arun's solution is wrong in two respects: it fails to add condition1 to the random numbers, and it feeds differently-sized

Re: [R] Performing operations only on selected data

2012-11-25 Thread Marcel Curlin
Thank you, this works very well. My only remaining question about this is about how ifelse is working; I understand the basic syntax (df$condition2 gets assigned the value *runif(nrow(df1[df1$condition1<=1,]),0,1)* or the value *df$condition1* depending on whether or not df$condition1 meets the cri

Re: [R] Performing operations only on selected data

2012-11-24 Thread Jeff Newmiller
?ifelse --- Jeff NewmillerThe . . Go Live... DCN:Basics: ##.#. ##.#. Live Go... Live: OO#.. Dead: OO#.. Playing Research Enginee

[R] Performing operations only on selected data

2012-11-24 Thread Marcel Curlin
I spent some time on this simple question, also searched the forum, eventually hacked my way to an ugly solution for my particular problem but I would like to improve my coding: I have data of the form: df <- expand.grid(group=c('copper', 'zinc', 'aluminum', 'nickel'), condition1=c(1:4)) I would