我有这个数据序列,我想每3行创建一个ID:
x <- c ("info","x1","y1","z1","x2","y2","z2")
df <- read.csv(text = x , strip.white = TRUE)
实际字符串没有任何逻辑信息,我可以使用mutate + ifelse + grepl创建ID列。我想创建一个每3行有一个序列号的新列:
id info
1 x1
1 y1
1 z1
2 x2
2 y2
2 z2