I want to create a vector or a list in a dataset concatenating the scores of several columns in another dataset.
I can do it like this:
my_vec <- c(x$v1, x$v2, x$v3...)
But I would need like 60 lines of code. I am pretty sure there is another way of doing it. When I try this:
my_vec <- c(x$v1:x$v644)
I get this error message
Warning messages:
1: In t$`1`:t$`644` :
numerical expression has 20 elements: only the first used
My dataset looks like this
x <- read.table(
text = " v1 v2 V3
0 1 0
1 0 1
0 0 0
0 0 1
1 0 0",
header = TRUE
)
And as an output I would like just a vector with values for each column one after the other, like this:
my_vec <- c(0, 1, 0, 0, 1, 1, 0, 0, 0, 0, 0, 1, 0, 1, 0)