I've created a matrix of values from a simulation that is stored in 20x7 matrix (20 observations across 7 columns of numbers; the matrix is called output). The columns are output from a simulation.
After running the simulation, I included column names:
colnames(output) <- c('level', 'value1','value2','value3',
And the matrix looks nice and clean. when observing:
Is there a way to plot these columns from the matrix? I've tried the code below (and other variants), but it will not work.
To index the matrix you use
output[,'level'], i.e. "any row, the 'level' column".
For your interest, you could also make a data frame from your matrix and plot like so:
df <- data.frame(output) plot(value1 ~ level,df)
Not worth doing if all you are doing with
output is plotting, but if you are doing other sorts of analysis on
output in R, a dataframe can be handy (and then you can refer to columns like
output$value1 whereas with a matrix you have to do