R

Asked • 06/19/19

How to sum a variable by group?

Let's say I have two columns of data. The first contains categories such as "First", "Second", "Third", etc. The second has numbers which represent the number of times I saw "First".For example: Category Frequency First 10 First 15 First 5 Second 2 Third 14 Third 20 Second 3I want to sort the data by Category and sum the Frequencies: Category Frequency First 30 Second 5 Third 34How would I do this in R?

1 Expert Answer

By:

Benjamin B. answered • 06/21/19

Tutor
4.9 (35)

Ecologist with 4 years of R and research experience

Still looking for help? Get the right answer, fast.

Ask a question for free

Get a free answer to a quick problem.
Most questions answered within 4 hours.

OR

Find an Online Tutor Now

Choose an expert and meet online. No packages or subscriptions, pay only for the time you need.