0

Each row of data in my df is from a study (or "Article"). Each Article has a sponsor ("Sponsor") who may have sponsored a number of the articles in my dataset.

I want to produce a summary table to show how many articles each Sponsor has sponsored in my dataset.

I hope you can help!

many thanks!!!!

Annabel

  • 3
    An example of your df would be helpful. https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example – S Rivero Aug 31 '18 at 13:29

2 Answers2

0

What I presume your dataframe looks like:

df=data.frame(article=1:10,sponsor=letters[round(runif(10,1,5))])
head(df)
  article sponsor
1       1       a
2       2       b
3       3       e
4       4       d
5       5       e
6       6       b

How you could quickly check the number of articles per sponsor:

table(df$sponsor)
Wave
  • 1,216
  • 1
  • 9
  • 22
0

I'm not sure what you want to do exactly, but I guess what you are looking for is:

table(df$Sponsor)

If you want the value that occurs the most frequent, you can use:

names(sort(table(df$Sponsor), decreasing=TRUE))[1]

next time, please try to provide a MWE so it is easier for us to help.

JtenBulte
  • 36
  • 6