lundi 30 juillet 2018

Compare the present value with the previous value in R while in ifelse()

I was working on a project in which if I want to compare the present value with the previous value and return an output 1 if true and 0 if false.

I tried

brv_trx1$'first' <- ifelse(brv_trx1$`Total TRx` != lag(brv_trx1$`Total TRx`),1,0)

This code did not work as expected. There was few errors in the

Aucun commentaire:

Enregistrer un commentaire