Error : Error in grouped_df_impl(data, unname(vars), drop) : Column col1
is unknown
pivot <- function(df, col1, col2){
df %>%
group_by(col1, col2) %>%
summarise(n = n()) %>%
spread(col2, n, fill = 0)
}
Running the command pivot (iris, Species, Petal.Width)
Can anyone tell why this error message ? and how to solve it