I have a dataframe where values above certain level in one vector should be changed in next vector.
I have tried if function, which gives back 'NA'.
if (mydata$duration >15) {
mydata$code==3
}
Here's some code of what the end function should look like labelled 'recode'
duration<-c(1,14,5,17,9,10,14,16,2,8,3,18)
code<-c(1,2,1,2,1,2,1,2,1,2,1,2)
mydata<-data_frame(code,duration)
recode<-c(1,2,1,3,1,2,1,3,1,2,1,3)
mydata<-data_frame(recode,duration)
Aucun commentaire:
Enregistrer un commentaire