I am trying to retrieve the column names of the data set model$data using the following formula:
sample(colnames(model$data),1)
When I run it I receive the following error message:
Error in sample.int(length(x), size, replace, prob) :
invalid first argument
Appreciate any help!
str(model) looks like this:
> str(model)
List of 13
$ data :List of 1
..$ : num [1:1000, 1:56] 1 1 1 1 0 1 1 0 1 1 ...
.. ..- attr(*, "dimnames")=List of 2
.. .. ..$ : chr [1:1000] "7530" "5975" "552" "815" ...
.. .. ..$ : chr [1:56] "Agriculture_and_Hunting" "Baking" "Biochemistry" "Braiding" ...
$ unit.classif : num [1:1000] 3 5 5 5 16 3 5 1 3 3 ...
$ distances : num [1:1000] 0.000806 0.000239 0.000239 0.000239 0.001953 ...
$ grid :List of 6
..$ pts : num [1:25, 1:2] 1.5 2.5 3.5 4.5 5.5 1 2 3 4 5 ...
.. ..- attr(*, "dimnames")=List of 2
.. .. ..$ : NULL
.. .. ..$ : chr [1:2] "x" "y"
..$ xdim : num 5
..$ ydim : num 5
..$ topo : chr "hexagonal"
..$ neighbourhood.fct: Factor w/ 2 levels "bubble","gaussian": 1
..$ toroidal : logi FALSE
..- attr(*, "class")= chr "somgrid"
$ codes :List of 1
..$ : num [1:25, 1:56] 0.000388 0.99996 1 1 1 ...
.. ..- attr(*, "dimnames")=List of 2
.. .. ..$ : chr [1:25] "V1" "V2" "V3" "V4" ...
.. .. ..$ : chr [1:56] "Agriculture_and_Hunting" "Baking" "Biochemistry" "Braiding" ...
$ changes : num [1:100, 1] 0.00261 0.00263 0.00262 0.00254 0.00254 ...
$ alpha : num [1:2] 0.05 0.01
$ radius : Named num [1:2] 3 0
..- attr(*, "names")= chr [1:2] "67%" ""
$ user.weights : num 1
$ distance.weights: num 1
$ whatmap : int 1
$ maxNA.fraction : int 0
$ dist.fcts : chr "sumofsquares"
- attr(*, "class")= chr "kohonen"
model
or better still a complete reproducible example showing us how to create a basicmodel
object that exhibits this behaviour. $\endgroup$