I want to combine vectors of values, each currently saved as a row in a matrix, into single cells, with values separate by commas.
My current code creates random vectors.
For instance,
## Group 1
N <- 10
set.seed(06510)
grp1 <- t(replicate(N, sample(seq(1:4), 4, replace = FALSE)) )
The results look like
Table 1:
[,1] [,2] [,3] [,4]
[1,] 2 4 3 1
[2,] 4 2 1 3
[3,] 2 4 1 3
[4,] 1 4 3 2
[5,] 1 3 2 4
[6,] 2 1 3 4
[7,] 4 3 2 1
[8,] 4 1 3 2
[9,] 2 4 3 1
[10,] 1 4 2 3
But I want the results to look like:
Table 2:
[,1]
[1,] 2,4,3,1
[2,] 4,2,1,3
[3,] 2,4,1,3
[4,] 1,4,3,2
[5,] 1,3,2,4
[6,] 2,1,3,4
[7,] 4,3,2,1
[8,] 4,1,3,2
[9,] 2,4,3,1
[10,] 1,4,2,3
I'm creating a randomization table and each cell represents the ordering of 4 survey questions for each survey respondent. Ultimately, I want to create multiple columns like the one above, so maintaining 4 columns for every randomization item will make for a big hard-to-read randomization table.