I wanna display some data which there are subsets of a dataframe called "don" but there are errors like this> L=as.numeric(levels(factor(don$Id_Cara))) > for(i in L){+ donC(i)=subset(don, Id_Cara == i, select = c( Id_TrT1, Id_Geno, Id_Rep, Val_O)) + donC(i) + } Erreur dans donC(i) = subset(don, Id_Cara == i, select = c(Id_TrT1, Id_Geno, : impossible de trouver la fonction "donC<-" I understand that the problem comes from the third line it doesn't reconize "donC(i)" but it's very important to make one "boucle" (in french) on the L's elements. to tell more about L :> L[1] 103 137 138 177 193 308 ___________________________________________________________________________ [[alternative HTML version deleted]]
Hi you shall: use appropriate subject e.g. how to subset data use [ ] brackets initialize object donC before using it for assignment and maybe try to look to some docummentation how to manipulate R objects (Paul Johnsons R tips are easily found by Google and they help me a lot during my first steps) BTW split(don[, some.columns], don$Id_Cara) could maybe do what you want without using for cycle Regards Petr Pikal petr.pikal at precheza.cz r-help-bounces at stat.math.ethz.ch napsal dne 24.04.2007 11:48:48:> I wanna display some data which there are subsets of a dataframe called"don"> but there are errors like this > > > L=as.numeric(levels(factor(don$Id_Cara))) > > for(i in L){ > + donC(i)=subset(don, Id_Cara == i, select = c( Id_TrT1, Id_Geno,Id_Rep, Val_O))> + donC(i) > + } > Erreur dans donC(i) = subset(don, Id_Cara == i, select = c(Id_TrT1,Id_Geno, :> impossible de trouver la fonction "donC<-" > > I understand that the problem comes from the third line > > it doesn't reconize "donC(i)" but it's very important to make one"boucle"> (in french) on the L's elements. > > to tell more about L : > > > L > [1] 103 137 138 177 193 308 > > > >___________________________________________________________________________> > > > > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help at stat.math.ethz.ch mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guidehttp://www.R-project.org/posting-guide.html> and provide commented, minimal, self-contained, reproducible code.
Are you trying to create a 'list' of the subsets? If so, try: L=as.numeric(levels(factor(don$Id_Cara))) donC <- list() for(i in L){ donC[[i]] <- subset(don, Id_Cara == i, select = c( Id_TrT1, Id_Geno, Id_Rep, Val_O)) print(donC[[i]]) } Or better using the 'names' of the factors L <- levels(factor(don$Id_Cara)) donC <- list() for(i in L){ donC[[i]] <- subset(don, Id_Cara == i, select = c( Id_TrT1, Id_Geno, Id_Rep, Val_O)) print(donC[[i]]) } On 4/24/07, elyakhlifi mustapha <elyakhlifi_mustapha at yahoo.fr> wrote:> I wanna display some data which there are subsets of a dataframe called "don" but there are errors like this > > > L=as.numeric(levels(factor(don$Id_Cara))) > > for(i in L){ > + donC(i)=subset(don, Id_Cara == i, select = c( Id_TrT1, Id_Geno, Id_Rep, Val_O)) > + donC(i) > + } > Erreur dans donC(i) = subset(don, Id_Cara == i, select = c(Id_TrT1, Id_Geno, : > impossible de trouver la fonction "donC<-" > > I understand that the problem comes from the third line > > it doesn't reconize "donC(i)" but it's very important to make one "boucle" (in french) on the L's elements. > > to tell more about L : > > > L > [1] 103 137 138 177 193 308 > > > > ___________________________________________________________________________ > > > > > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help at stat.math.ethz.ch 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. >-- Jim Holtman Cincinnati, OH +1 513 646 9390 What is the problem you are trying to solve?