I have a dataframe:
Store <- c('A','A','A', 'B','C','C')
Main_or_branch <- c('main', 'Branch','Branch','main','main', 'Branch')
flavor <- c('chocolate', 'N/A','N/A', 'vanilla', 'strawberry','N/A')
df <- data.frame(Store, Main_or_branch, flavor)
and it looks like this:
Store Main_or_branch flavor
<fct> <fct> <fct>
1 A main chocolate
2 A Branch N/A
3 A Branch N/A
4 B main vanilla
5 C main strawberry
6 C Branch N/A
I'm trying to use group by and fill :
df %>% group_by(Store) %>% fill(flavor)
but my output still looks like this
Store Main_or_branch flavor
<fct> <fct> <fct>
1 A main chocolate
2 A Branch N/A
3 A Branch N/A
4 B main vanilla
5 C main strawberry
6 C Branch N/A
Does anyone know what the issue could be? Thanks!