Since a function that I use requires a table object as parameter, I would like to convert a multidimensional array to a table, but I have problems with dimension names.
as.table
doesn't have a dnn
argument. You need to set the dimnames manually.
my2dimdata <- array(c(1,0,0,0,1,2,0,0,1),dim=c(3,3),
dimnames=list(c("a","b","c"),
c("1","2","3")))
my2dimdata <- as.table(my2dimdata)
names(attributes(my2dimdata)$dimnames) <- c("letters","numbers")
# numbers
# letters 1 2 3
# a 1 0 0
# b 0 1 0
# c 0 2 1