Try to search your question here, if you can't find : Ask Any Question Now ?

Create a vector or a list with the content of several columns

HomeCategory: stackoverflowCreate a vector or a list with the content of several columns
craig asked 2 weeks ago

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$v1 x$v2 x$V3
  • 0 1 0
  • 1 0 1
  • 0 0 0
  • 0 0 1
  • 1 0 0

And as an output I would like just a vector with values for each column one after the other, like this:

my_vec<-0 1 0 0 1 1 0 0 0 0 0 1 0 1 0

Any ideas/help, please?
THANKS =)

1 Answers
Best Answer
Amit answered 2 weeks ago
Your Answer

8 + 6 =

Popular Tags

WP Facebook Auto Publish Powered By : XYZScripts.com