Creating tuples from two vectors

后端 未结 4 2036
余生分开走
余生分开走 2020-12-31 00:46

If I have two vectors of the same length A<-c(5,10) and B<-c(7,13) how can I easily turn these two vectors into a single tuple vector i. e. <

4条回答
  •  滥情空心
    2020-12-31 01:22

    I'm not certain this is exactly what you're looking for, but:

    list(A, B)

    which gives you a structure like this:

    > str(list(A, B))
    List of 2
     $ : num [1:2] 5 10
     $ : num [1:2] 7 13
    

    and is literally represented like this:

    dput(list(A, B)) list(c(5, 10), c(7, 13))

    ... which is about as close to the suggested end result as you can get, I think.

    A list in R is essentially a vector of whatever you want it to be.

    If that isn't what you're looking for, it might be helpful if you could expand on what exactly you'd like to do with this vector.

提交回复
热议问题