Hi,
Try this:
dat1<-data.frame(var1=15:25)
dat1$var2<-NA
dat1$var2[2:11]<-dat1$var1[1:10]
dat1
var1 var2
1 15 NA
2 16 15
3 17 16
4 18 17
5 19 18
6 20 19
7 21 20
8 22 21
9 23 22
10 24 23
11 25 24
You can also do the same within the sin
Hi Ernie,
I'll use the built in mtcars dataset for demonstrative purposes.
You have some condition, which can be used to create an index
## show data frame
mtcars
## create index based on your condition
i <- which(mtcars$carb == 1)
## set those rows of mtcars in your index
## to the index - 1
mt
2 matches
Mail list logo