mardi 4 décembre 2018

programming R function ifelse previous row

when i have this data.frame

x<- c(1,2,3,1,2,3,1,2,3,.......etc.) 
y<-c(M,P,P,M,S,M,M,S,P,S,P,M,...) 

2 milion rows and i need create next columns . Next columns should look as

z<-c(M,MP,MPP,M,MS,MSM,M,MS,MSP,S,SP,SPM,....) 

I use base package. I do not want to use cycle- loop.

Aucun commentaire:

Enregistrer un commentaire