If I have data like this in R:
> a = data.frame(a = c(1, 2),
b = c(3, 4))
> a
a b
1 1 3
2 2 4
but I would like to have it like this:
> b = data.frame(k = c("a", "a", "b", "b"),
+ v = c(1, 2, 3, 4))
> b
k v
1 a 1
2 a 2
3 b 3
4 b 4
How can I convert the data this way?
b
does not actually represent key-value pairs because it contains non-unique keys, which goes against the logic of key-value pairs. $\endgroup$