I have some data which has features which are of the same "class" (or type).
x <- tibble(char = c("a", "b", "c", "d"), x1 = c(1:4), x2 = c(11:14))
x
# A tibble: 4 x 3
char x1 x2
<chr> <int> <int>
1 a 1 11
2 b 2 12
3 c 3 13
4 d 4 14
Now, I what I am looking for is a function to collapse x1
and x2
into a single column x
.
y <- some_transformation_function(x)
y
# A tibble: 8 x 2
char x
<chr> <int>
1 a 1
2 b 2
3 c 3
4 d 4
5 a 11
6 b 12
7 c 13
8 d 14
I am not looking for a function that modifies the data in anyway (which is what existing questions seem to answer - I haven't found a similar question to what I'm asking).