Home > OS >  Make a dataframe with artist, song and duration variables
Make a dataframe with artist, song and duration variables

Time:11-11

I'm new with tidyverse in R.

I have a dataframe radio, from a radio channel, from a specfic date with variables: artist, song, duration.

My aim is to find which artist that has the most different songs playing on the choosen date.

 radio %>% select(artist, song) %>% arrange...

and then I'm lost. Please help if anyone is good at this.

CodePudding user response:

you can group_by artist song and then compute the different songs:

radio %>% 
  select(artist, song) %>%
  group_by(artist) %>%
  summarise(n_song = n_distinct(song), .groups = "drop") %>%
  arrange(-n_song)
  •  Tags:  
  • r
  • Related