1

I have a data frame that looks something like this

Player Surface
Mike Grass
Mike Concrete
Mark Clay
Mike Clay
Mark Clay

I want to make another data frame which would like something like this

Player Grass Concrete Clay
Mike 1 1 1
Mark 0 0 2

I found some old threads and using a reshape package but I couldn't quite figure out how exactly it is used.

Any help is appreciated.

1 Answers1

0

We can use table from base R

table(df1)

If there are many columns, subset the dataset by selecting those specific columns and then apply the table

table(df1[c("PLAYER", "SURFACE")])
akrun
  • 874,273
  • 37
  • 540
  • 662
  • 1
    Oh wow, it was that simple... Thank you! –  Dec 08 '20 at 23:08
  • 1
    Unfortunately I can't upvote it as I don't have enough reputation. I will accept it as soon as the cooldown runs out. –  Dec 08 '20 at 23:12