0

This should be very simple, but I cannot find out how to do it.

Suppose I have the vector: ('cat', 'hat', 'hat', 'mouse').

I would like to group by each word in the vector and calculate the number of times the word occured. The output should be

'cat':1

'hat':2

'mouse':1

How do you do this in R?

phil
  • 225
  • 1
  • 4
  • 13

1 Answers1

0

With table

table( c('cat', 'hat', 'hat', 'mouse') )
Sirius
  • 5,224
  • 2
  • 14
  • 21