I have samples A:Z and I want to make a matrix that have sample column and another value column with all 1's.
result should look like this.
samples values
A 1
B 1
C 1
D 1
. .
. .
Z 1
I have samples A:Z and I want to make a matrix that have sample column and another value column with all 1's.
result should look like this.
samples values
A 1
B 1
C 1
D 1
. .
. .
Z 1
Use cbind
to create a matrix
cbind(samples, values=1)
but matrix
can hold only a single class
so the output columns will be 'character'
I would suggest to use data.frame
to hold columns of different class.
data.frame(samples, values=1)
If we want the 'samples' column to be character
class, use option stringsAsFactors=FALSE
. The default is TRUE
.