Consider a table:
ta <- structure(c(`0` = 1L, `2` = 3L, `4` = 4L, `5` = 2L), .Dim = 4L, .Dimnames = list(
x = c("0", "2", "4", "5")), class = "table")
#> ta
# x
# 0 2 4 5
# 1 3 4 2
With simple table, the conventional way (as.data.frame.matrix) does not seem to work:
> as.data.frame.matrix(ta)
Error in d[[2L]] : subscript out of bounds
So, is there an easy way to convert a table with one row to a data frame? So far, the only way I came up with is
as.data.frame(t(as.data.frame.array(ta)))
0 2 4 5
ta 1 3 4 2
Is there an easier way?