The following snippet shows how to shift one of the column values upward by "n" rows.
class(iris)
#move 10 rows forward on SepalLength
shiftBy <- 10
sepalLenCol <- iris$Sepal.Length
sepalLenCol <- (tail(sepalLenCol,-shiftBy))
len <- (nrow(iris)-shiftBy)
finalOutput <- iris[(1:len),]
finalOutput$Sepal.Length <- sepalLenCol
write.csv(finalOutput, file = "modified.csv")
No comments:
Post a Comment