[R] Dataframe and conditions

Rui Barradas ruipbarradas at sapo.pt
Tue May 14 10:35:11 CEST 2013


Hello,

Try the following.

X$a[X$b] <- X$c[X$b]


Hope this helps,

Rui Barradas

Em 14-05-2013 09:06, fgrelier escreveu:
>
> I have in a dataframe X  :  3 Variables X$a , X$b, X$c
> I would like to replace in X the values of X$a by the values of  X$c but
> only when X$b=="TRUE"
> I have tried to put in place a loop but as I have a lot of rows it is very
> very long to run.
>
> Thanks for your help
>
>
>
>
>
> --
> View this message in context: http://r.789695.n4.nabble.com/Dataframe-and-conditions-tp4667012.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> R-help at r-project.org 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