data <- c( 1, 2, 4, 5, 6, 1, 2, 2, 4, 5)
data_table <- table(data)
class(data_table)
# [1] "table"
data_table
# data
# 1 2 4 5 6
# 2 3 2 2 1
I think the row of numbers (1 2 3 4 5 6) are the names for each column. The second row of numbers are numeric.
Now I do not know how to extract the second row of numbers from this table. For example,
data_table[1]
# 1
# 2
class(table_data[1])
# [1] "integer"
Now I want to get the number 2 in the first element of this table. I tried several ways and all failed. I am a beginning learner for R language. Could anyone explain the method and reason? Any help is appreciated.