[R-sig-Finance] How to get values from dataframe's column conditional on other column
Gabor Grothendieck
ggrothendieck at gmail.com
Tue Jun 13 14:02:14 CEST 2006
If DF is your data.frame
with(DF, X[Y])
or
DF$X[DF$Y]
On 6/13/06, Yuri Volchik <volchik2000 at list.ru> wrote:
> Hi to all members of this list,
>
> I'm quite a novice to R and was wondering if there is a more elegant
> way to solve a following problem:
> Suppose we have a dataframe
> X Y
> .12 TRUE
> -.24 TRUE
> .. ...
> .34 FALSE
>
> i.e. two (or more columns) with data and we want to get vector of X
> values conditional on Y values (say only X's when Y=TRUE).
> Of course it is possible to do it by looping through the whole
> dataframe, i was wondering if there is a a more elegant solution to
> this in R?
>
> --
> Best regards,
> Yuri mailto:volchik2000 at list.ru
>
> _______________________________________________
> R-SIG-Finance at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-sig-finance
>
More information about the R-SIG-Finance
mailing list