I have a question about cbinding recycled items. I simplified my problem into the following code.
I have two objects "a" and "b". "a" has 5 rows and "b" has 10 rows.
When I cbind them, I get a data.frame with 10 rows, and my column "a" recycles until it reaches 10 rows. My problem is, how do i recycle the values so it adds to the length(a). Thanks!
a <- c(4, 3, 5, 2, 8)
b <- c(1:10)
cbind(a,b)
a b
1 4 1
2 3 2
3 5 3
4 2 4
5 8 5
6 4 6
7 3 7
8 5 8
9 2 9
10 8 10
What I want to do: a[6] = a[5] + 4, a[7] = a[5] + 5, ... a[10] = a[5] + 8
a b
1 4 1
2 3 2
3 5 3
4 2 4
5 8 5
6 12 6
7 11 7
8 13 8
9 10 9
10 16 10