how can we assign names to rows and columns of a array in R. below is what i tried using.
a<- array(1:50,dim = c(25,2),dimnames = list("Col1","col2"))
thanks
We need to specify the rownames and column names. Below, we are assuming the rownames to be NULL and the column names as 'Col1' and 'Col2'
out <- array(1:50,dim = c(25,2), dimnames = list(NULL, c("Col1", "Col2")))
According to ?array
dimnames: either ‘NULL’ or the names for the dimensions. This must a list (or it will be ignored) with one component for each dimension, either ‘NULL’ or a character vector of the length given by ‘dim’ for that dimension. The list can be named, and the list names will be used as names for the dimensions. If the list is shorter than the number of dimensions, it is extended by ‘NULL’s to the length required.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With