データフレームがあり、カテゴリ内の数列に基づいdf
てサブセット化したい。df
x <- c(1,2,3,4,5,7,9,11,13)
x2 <- x+77
df <- data.frame(x=c(x,x2),y= c(rep("A",9),rep("B",9)))
df
x y
1 1 A
2 2 A
3 3 A
4 4 A
5 5 A
6 7 A
7 9 A
8 11 A
9 13 A
10 78 B
11 79 B
12 80 B
13 81 B
14 82 B
15 84 B
16 86 B
17 88 B
18 90 B
1ずつ増加する行だけが必要で、2つ増加するx
行は必要ありません。x
x y
1 1 A
2 2 A
3 3 A
4 4 A
5 5 A
10 78 B
11 79 B
12 80 B
13 81 B
14 82 B
要素間で少し引き算をして、違いがあるかどうかを確認>1
し、これをaと組み合わせる必要があると思いましたddply
が、これは面倒なようです。sequence
欠けている機能はありますか?