I have a frequency table, counting the frequency of elements in a vector
a = table(c(0,1,1,1,0,2,2,4,1,2,3,2,1,2,3,1,1,1,2,3,4,1,1,0))
a
# 0 1 2 3 4
# 3 10 6 3 2
I know I can access the name by names(a). But when I tried to access the values of the SECOND row
a[1, "0"]
# Error in a[1, "0"] : incorrect number of dimensions
a[1, 1]
# Error in a[1, 1] : incorrect number of dimensions
This table is actually an array.
Its names are on top, and values on bottom.
You can access its elements a number of ways.
It also has an
nrowanddimattribute, which are set up in the last few lines oftable.Although it's really not clear to me why
nrow(a)is 5 buta[1,]returns an error.