[R] TRUE/FALSE as numeric values
Chuck Cleland
ccleland at optonline.net
Fri Feb 23 14:50:44 CET 2007
Thomas Preuth 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?
This is covered in
http://cran.r-project.org/doc/manuals/R-intro.html
(Section 2.7; Index vectors; selecting and modifying subsets of a data set)
RSF_EU$AREA[RSF_EU$AREA <= x]
or to retain other columns in the data frame
subset(RSF_EU, AREA <= x)
> 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.
--
Chuck Cleland, Ph.D.
NDRI, Inc.
71 West 23rd Street, 8th floor
New York, NY 10010
tel: (212) 845-4495 (Tu, Th)
tel: (732) 512-0171 (M, W, F)
fax: (917) 438-0894
More information about the R-help
mailing list