[R] TRUE/FALSE as numeric values
Ranjan Maitra
maitra at iastate.edu
Fri Feb 23 14:45:33 CET 2007
On Fri, 23 Feb 2007 14:38:56 +0100 Thomas Preuth <preuth at slf.ch> wrote:
> Hello,
>
> I want to select in a column of a dataframe all numbers smaller than a
> value x
> but when I type in test<-(RSF_EU$AREA<=x) I receiv as answer:
> > test
> [1] TRUE FALSE FALSE TRUE TRUE TRUE FALSE FALSE TRUE TRUE TRUE
> FALSE TRUE TRUE TRUE TRUE TRUE
> [18] TRUE TRUE TRUE TRUE FALSE FALSE TRUE TRUE TRUE TRUE TRUE
> TRUE TRUE FALSE TRUE TRUE TRUE
> [35] FALSE TRUE TRUE TRUE TRUE FALSE FALSE FALSE TRUE TRUE FALSE
> TRUE TRUE FALSE FALSE TRUE FALSE
> [52] TRUE TRUE TRUE TRUE TRUE FALSE TRUE TRUE FALSE TRUE
>
> How can i get the values smaller than x and not the TRUE/FALSE reply?
if the dataframe is called RSF_EU, and you want the entire dataframe for those rows, then
RSF_EU [ (RSF_EU$AREA <= x ), ]
if you want to get only that column vector and nothing else
RSF_EU$AREA [ ( RSF_EU$AREA <= x ) ]
Such concepts are very well-explained in "An Introduction to R" which you would benefit by reading at the earliest.
Ranjan
> Thanks in advance,
> Thomas
>
> ______________________________________________
> 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.
>
More information about the R-help
mailing list