Re: [R] Compare two subsequent rows based on specific values of a string

2013-09-20 Thread Michel
Thanks I'm lookin for yur example -Message d'origine- De : r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] De la part de arun Envoyé : vendredi 20 septembre 2013 18:11 À : R help Objet : Re: [R] Compare two subsequent rows based on specific values of a strin

Re: [R] Compare two subsequent rows based on specific values of a string

2013-09-20 Thread arun
Hi, May be this helps: dat1<- read.table(text="x1    x2    x3   x4  1 xz   ab    cd    ef 2 ab   fz    cd    ef 3 ab   cd   dy    dx",sep="",header=TRUE,stringsAsFactors=FALSE) dat1$changes_to_row_above<- sapply(seq_len(nrow(dat1)),function(i) {x1<-dat1[,i]%in% dat1[,i-1];if(any(x1))