I have a matrix that looks like this:
> m <- cbind( c(1, 0), c(1, 1) )
> rownames(m) <- c('ON', 'OFF')
> colnames(m) <- c('ON', 'OFF')
> m
ON OFF
ON 1 1
OFF 0 1
How can I provide a header name for rows and columns? For instance.
thermostat
ON OFF
motion_sensor ON 1 1
OFF 0 1
I looked at ?dimnames, but could not figure / understand how to do this.
source
share