You can try this
my.data <- data.frame(words=c("home", "paper", "letter"),
frequency=c(1, 5, 6))
my.tbl <- xtabs(frequency ~ words, data=my.data)
is.table(my.tbl) # TRUE
質問
Using R, I converted a frequency table (created using the table()
function) to a data-frame. My data frame now looks as follows:
words frequency
1 'home' 1
2 'paper' 5
3 'letter' 6
Now I want to convert this data frame back into a table()
object.
How?
解決
You can try this
my.data <- data.frame(words=c("home", "paper", "letter"),
frequency=c(1, 5, 6))
my.tbl <- xtabs(frequency ~ words, data=my.data)
is.table(my.tbl) # TRUE