Honestly, it could not be easier. If you cannot understand this, you will have many other problems:
> set.seed(42) ## be reproducible
> X <- sample(1:5, 50, replace=TRUE) ## our data
> table(X) ## our table
X
1 2 3 4 5
7 6 9 10 18
> str(table(X)) ## look at structure of object
'table' int [1:5(1d)] 7 6 9 10 18
- attr(*, "dimnames")=List of 1
..$ X: chr [1:5] "1" "2" "3" "4" ...
> as.numeric(table(X)) ## and just convert to vector
[1] 7 6 9 10 18
>
And for completeness, there are two more ways to get data:
> unname(table(X))
[1] 7 6 9 10 18
> table(X)[]
[1] 7 6 9 10 18
>
source
share