简体   繁体   中英

How to count and tally numbers within a vector defined as a class object 'character'?

I am analyzing a survey, which is set out with the number of the question as a column while numbers are given to represent the answer. Ie

Ques1 
1
1
2
1
2
3
-1 ...

I am trying to count the number of occurrences from these numbers. Yet when I try to tally it says that "no applicable method for 'tbl_vars' applied to an object of class "character" how do i get it to count the number of occurrences?

Hi just try table(Ques1) if all of your data is in a single vector.

If you data is inside a data.frame and Ques1 is just one column, try table(yourdata$Ques1) .

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM