1

Very simple concept:

data(iris)
d1=as.matrix(iris)
d2=as.array(iris)
Error in <code>dimnames<-.data.framecode>(<code>*tmp*code>, value = list(n)) :invalid 'dimnames' given for data frame

i have made many kinds of dimnames ,failed . how to make as.array(iris) to be successful?

Fnzh Xx
  • 661
  • 2
  • 8
  • 14

1 Answers1

1

You can either choose one of the dimensions (and then you don't even need as.array) or you can flatten everything using c(). Examples:

iris$Petal.Length
c(iris, recursive=T)

To get the dimension names you can use in the first case, type names(iris).

Lars Kotthoff
  • 107,425
  • 16
  • 204
  • 204