R, Excel, Function, Pivot Tables.
above, we can repeat the command using different diamond features. table2= diamonds %>% group_by(clarity,cut) %>% summarize(mean.value=mean(carat)) %>% spread(clarity,mean.value) But given the repetitive nature of the table creation, let’s write a function to do the job; call it excel.func.