thank you very much Allan it works!!
________________________________ De : Allan Engelhardt <all...@cybaea.com> Cc : r-help@r-project.org Envoyé le : Jeudi, 13 Août 2009, 10h10mn 14s Objet : Re: [R] for(variable in [])do On 13/08/09 08:55, Inchallah Yarab wrote: > [...] >> for (LRPhase in c(-1,1)) >> > + {Phase1<- output[output[,2]==LRPhase,]} > >> Phase1<- Phase1[order (Phase1[,6]),] >> [...] > > why when i write for LRPhase in c(1,-1), it gives me the result only for > Phase = 1?? > Because you re-assign the Phase1 variable in the for loop. At the end of the loop it has the value you set during the last iteration, i.e. LRPhase==1 since you used c(-1,1) in the code (and not c(1,-1) as in your question). Try for (LRPhase in c(-1,1)) { Phase1<- output[output[,2]==LRPhase,] Phase1<- Phase1[order (Phase1[,6]),] print(Phase1) } Hope this helps a little Allan [[alternative HTML version deleted]]
______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.