user.bayes
user.bayes

Reputation: 43

R Table data with a grouping command

This seems like a very simple problem, but I can't seem to sort it out. I have sought help from this forum, with the below topics being close, but don't seem to do exactly what I need. I have count data over several years. I want to obtain frequencies of the count value by year. It seems I need a table function with a grouping option, but I haven't found the proper syntax.

Data:
          count year
    1        15 1957
    2         6 1957
    3        23 1957
    4        23 1957
    5         2 1957
    6        28 1980
    7        15 1980
    8        32 1980
    9        18 1981

thank you in advance!

Counting the number of elements with the values of x in a vector

grouping data splitted by frequencies

Aggregate data in R

Upvotes: 0

Views: 1246

Answers (1)

Justin
Justin

Reputation: 43245

You're looking for the table function. Something like:

with(yourdata, table(Year, Count))

Upvotes: 2

Related Questions