I have a contingency table t like
0 1 10 11 12 13 14 2 3 4 5 6 7 8 9
3780 3502 433 316 284 168 74 2104 1930 1560 1482 868 691 645 575
When I do names(t), I get
[1] "0" "1" "10" "11" "12" "13" "14" "2" "3" "4" "5" "6" "7" "8" "9"
which means that the names of the rows are strings of integers. I would like to sort the table so that the order is 0,1,2,3,..etc. How can I do this. I tried order(names(t)) but that dos not give the desired output.
我们可以对转换为numeric
的names
使用order
t1 <- t[order(as.integer(names(t)))]
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.