Pivot - restructure one table into another using a variable
Gather
{a, b, c, d, e} to alphabet = {}
Also known as pivot longer
pivot_longer
pivot_longer(
data,
cols,
names_to="name", # what you want the new column for all the old columns calledvalues_to="value", # what you want the values column to be called
)
Spread
alphabet = {} to {a, b, c, d, e}
Also known as pivot wider
pivot_wider
pivot_wider(
data,
cols,
names_from="name", # the column you want to split based onvalues_from="value", # the current values column
)
Need a bar chart to show a axis in a dataset?
geom_bar(mapping = aes(x = cut, y = freq), stat = "identity")