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

时间:2019-04-08 13:24:50

标签: r class

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. I.e

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?

1 个答案:

答案 0 :(得分:0)

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).