You can also use droplevels() on your new object (as of R 2.12). Cheers, Roman
On Sun, Apr 24, 2011 at 3:42 PM, Christian Parker <cpar...@pdx.edu> wrote: > You are creating a new object, but the columns that are stored as factors > are not being 'refactored' so you are retaining the original list of levels. > To fix this you can use the factor function after you subset > > pa2 = subset(pa, influencia=="AID") > pa2$influencia<-as.factor(pa2$influencia) > > > > On Apr 24, 2011, at 6:04 AM, Manuel Spínola <mspinol...@gmail.com> wrote: > > > Dear list members, > > > > I have a question regarding too subsetting a data set in R. > > > > I created an object for my data: > > > >> pa = read.csv("espec_indic.csv", header = T, sep=",", check.names = F) > > > >> levels(pa$influencia) > > [1] "AID" "AII" "AP" > > > > The object has 3 levels for influencia (AP, AID, AII) > > > > Now I subset only observations with influencia = "AID" > > > >> pa2 = subset(pa, influencia=="AID") > > > > but if I ask for the levels of influencia still show me the 3 levels, > > AP, AID, AII. > > > >> levels(pa2$influencia) > > [1] "AID" "AII" "AP" > > > > Why is that? > > > > I was thinking that I was creating a new data frame with only AID as a > > level for influencia. > > > > How can I make a complete new object with only the observations for > > "AID" and that the only level for influencia is indeed "AID"? > > > > Best, > > > > Manuel > > > > > > > > > > -- > > *Manuel Spínola, Ph.D.* > > Instituto Internacional en Conservación y Manejo de Vida Silvestre > > Universidad Nacional > > Apartado 1350-3000 > > Heredia > > COSTA RICA > > mspin...@una.ac.cr > > mspinol...@gmail.com > > Teléfono: (506) 2277-3598 > > Fax: (506) 2237-7036 > > Personal website: Lobito de río > > <https://sites.google.com/site/lobitoderio/> > > Institutional website: ICOMVIS <http://www.icomvis.una.ac.cr/> > > > > [[alternative HTML version deleted]] > > > > _______________________________________________ > > R-sig-ecology mailing list > > R-sig-ecology@r-project.org > > https://stat.ethz.ch/mailman/listinfo/r-sig-ecology > > _______________________________________________ > R-sig-ecology mailing list > R-sig-ecology@r-project.org > https://stat.ethz.ch/mailman/listinfo/r-sig-ecology > -- In God we trust, all others bring data. [[alternative HTML version deleted]]
_______________________________________________ R-sig-ecology mailing list R-sig-ecology@r-project.org https://stat.ethz.ch/mailman/listinfo/r-sig-ecology