mardi 7 novembre 2017

Using if/else query in r

I have this table call A and in this table I have column called 'Yfactor'

I am trying to insert Yfactor using if/else query, If the periodcode is 201706 then Yfactor is 0.8571 and if periodcode is 201707 then Yfactor is 1.1071

I have query like this but somehow I am keep getting error and not assign properly.

A <- ifelse([(A$PERIODCODE==20171406),]){A$YFACTOR=0.8571} else(A[(A$PERIODCODE==20171407),]){A$YFACTOR=1.1071}

Aucun commentaire:

Enregistrer un commentaire