I want to know how to get a specific row from a table in R. For example,
> a <- c(13,13,
14,14,14,14,14,14,
15,15,15,15,15,15,
16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,
17,17,17,17,17,17,17,
18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,
19,19,19,19,19,19,19,19,19,19,19,
20,20,20,20,20,20,20,20,20,
21,21,21,21,21,21,21,21,21,21,21,
22,22,22,22,22,22,22,22,22,
23,23,23,24,25,25,27)
> table(a)
a
13 14 15 16 17 18 19 20 21 22 23 24 25 27
2 6 6 15 7 17 11 9 11 9 3 1 2 1
How do I extract the last row of the table?
The function
str()
lets you interrogate the structure of an objectYour table object is similar to a vector (it just has some additional tags/attributes). Crucially, you can access the elements in the usual way:
Also, we can use standard sub-setting rules