Message-ID: <55B112E8.2090103@arpa.veneto.it>
Date: 2015-07-23T16:14:32Z
From: Massimo Bressan
Subject: shift by one column given rows in a dataframe
by considering the following reproducible example:
v0<-c("a","xxx","c",rep("xxx",2))
v1<-c(1,"b",3,"d","e")
v2<-c(6,2,8,4,5)
v3<-c("xxx",7,"xxx",9,10)
df_start<-data.frame(v0,v1,v2,v3)
df_start
v0<-letters[1:5]
v1<-1:5
v2<-6:10
df_end<-data.frame(v0,v1,v2)
df_end
I need to shift by one column some given rows in the initial data frame
called "df_start" so that to get the final structure as in "df_end";
please consider that the value "xxx" in the rows of "df_start" can be
anything so that I necessarly need to apply by row index position (in my
reproducible example rows: 2, 3, 5);
I'm really stuck with that problem and I can not conceive any viable
solution up to now
any hints?
best regards
m