[R] data frame handling

David Winsemius dwinsemius at comcast.net
Mon Aug 16 14:16:41 CEST 2010


On Aug 16, 2010, at 5:53 AM, Lily_stats wrote:

>
> Dear all,
>
> I have an xts object , t.xts with 4 columns: "v1" "DD1" "v2" "DD2" and
> created a data frame :
>
> t <- as.data.frame(t.xts)

"t" is not the best choice of names for an object because it is the  
name of a commonly used function

Let's instead assume you used "tt". Try:

tt[which(tt$DD1 >0 & tt$DD1 < 30), "v1"]

Or:

subset(tt, subset=which(tt$DD1 >0 & tt$DD1 < 30), select="v1")

>
> I would like to extract data and create a new data frame for when  
> the values
> in column DD1 falls between 0 and 30 and extract the corresponding  
> v1 value.
>
> How can I do this?
>
> Thanks.
>

David Winsemius, MD
West Hartford, CT



More information about the R-help mailing list