I have a matrix with columns containing 0s and 1s, and I want to concatenate the values in each row to create a new column in that matrix with that concatenated string.
I used
apply(format(matrix), 1, paste, collapse="")
from Concatenating N columns of text in R to create a list of concatenated values, but am having trouble getting those values into a new column in the matrix - the second line of this code has the wrong syntax.
my current code:
newcolumn <- rep(0,times=nrow(matrix))
newcolumn[matrix[apply(format(matrix), 1, paste, collapse="")]]
matrix <- cbind(matrix, newcolumn)