Dear list,
How can I subset a factor level out of a dataframe and into another?
Ex.
token max1 max2 condition prop1 prop2
879 n224ti10.10msmeanc 2928.516 6201.562 out of range 0.5273416 0.5454564
880 n224ti11.10msmeanc 3100.781 6718.359 out of range 0.7369985 0.4668726
881 n224tu01.10msmeanc 2928.516 6373.828 out of range 0.5116092 0.5293684
18 n002tu06.10msmeanc 2756.250 7579.688 within range 0.5245017 0.4614441
39 n011ku02.10msmeanc 1722.656 5340.234 within range 0.5297173 0.5002062
40 n011ku03.10msmeanc 1894.922 5167.969 within range 0.6348299 0.6518556
43 n011ku06.10msmeanc 1894.922 5512.500 within range 0.6487249 0.5513902
Suppose I need to subset all of the within range observations into another
dataframe.
Many thanks,
S. David White
sdavidwhite at bigfoot.com
Columbus, Ohio
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !) To: r-help-request at
stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
On Tue, 3 Jul 2001, David White wrote:> > Dear list, > > How can I subset a factor level out of a dataframe and into another? > > Ex. > token max1 max2 condition prop1 prop2 > 879 n224ti10.10msmeanc 2928.516 6201.562 out of range 0.5273416 0.5454564 > 880 n224ti11.10msmeanc 3100.781 6718.359 out of range 0.7369985 0.4668726 > 881 n224tu01.10msmeanc 2928.516 6373.828 out of range 0.5116092 0.5293684 > 18 n002tu06.10msmeanc 2756.250 7579.688 within range 0.5245017 0.4614441 > 39 n011ku02.10msmeanc 1722.656 5340.234 within range 0.5297173 0.5002062 > 40 n011ku03.10msmeanc 1894.922 5167.969 within range 0.6348299 0.6518556 > 43 n011ku06.10msmeanc 1894.922 5512.500 within range 0.6487249 0.5513902 > > Suppose I need to subset all of the within range observations into another > dataframe. >another.dframe<-dframe[dframe$condition=="within range",] -thomas -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
David White <dwhite at ling.ohio-state.edu> writes:>How can I subset a factor level out of a dataframe and into another? > >Ex. > token max1 max2 condition prop1 prop2 >879 n224ti10.10msmeanc 2928.516 6201.562 out of range 0.5273416 0.5454564 >880 n224ti11.10msmeanc 3100.781 6718.359 out of range 0.7369985 0.4668726 >881 n224tu01.10msmeanc 2928.516 6373.828 out of range 0.5116092 0.5293684 >18 n002tu06.10msmeanc 2756.250 7579.688 within range 0.5245017 0.4614441 >39 n011ku02.10msmeanc 1722.656 5340.234 within range 0.5297173 0.5002062 >40 n011ku03.10msmeanc 1894.922 5167.969 within range 0.6348299 0.6518556 >43 n011ku06.10msmeanc 1894.922 5512.500 within range 0.6487249 0.5513902 > >Suppose I need to subset all of the within range observations into another >dataframe.Use subset(). Something like: new.df <- subset(old.df, old.df$condition == "within range") should so it. You may also use indexes: new.df <- old.df[old.df$condition == "within range",] The last comma is important. Mark -- Mark Myatt -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._