Reputation: 5935
I am working with the R programming language. I am trying to follow the instructions over here: https://stat.ethz.ch/R-manual/R-devel/library/MASS/html/parcoord.html
library(MASS)
a = rnorm(100,10,10)
b = rnorm(100,10,5)
c = rnorm(100,5,10)
d = as.matrix(a,b,c)
parcoord(d[, c(3, 4, 2)], col = 1 + (0:149)%/%50)
It produces the following error:
Error in d[, c(3, 4, 2)] : subscript out of bounds
Calls: parcoord -> apply
Execution halted
Does anyone know how to fix this error? Is it also possible to label the axis and put a title on the plot?
Thanks
Upvotes: 0
Views: 6976
Reputation: 3257
The subscript is [ ,c(3,4,2)]
Out of bounds means that you're indexing columns that don't exist. This is because d
is a column vector - a matrix with only one column. This is happening because you're using as.matrix
incorrectly.
You could make a three column matrix with: d <- matrix(c(a, b, c), ncol = 3)
, but even then your subscript won't work, because your subscript is looking for column four.
Upvotes: 3