Quantcast
Channel: Active questions tagged r - Stack Overflow
Viewing all articles
Browse latest Browse all 201894

create a matrix of lists in r

$
0
0

I have a table with 1 column as a factor with 5 levels. I am extracting the unique factors set into a new data table TNAME and then want to put TNAME into a list and add a reference value 1-5 so essentially a matrix of 5x2 dimensions. How do I do this in R?

I tried:

list1 = list(split(TNAME, seq(nrow())), 1:5)

But that did not given me the intended result which looks below:

     [,1] [,2]
[1,] "a""1" 
[2,] "b""2" 
[3,] "c""3"

Viewing all articles
Browse latest Browse all 201894

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>