I am having trouble figuring out how to move around my variables/data in order to achieve a 3 column data frame. the original data frame contains 200+ columns and I want move the data around so that it looks like the example i have shown below.
Do not have very much background as I am Not sure how to start to transform my dataframe.
Candy_Hierarchy <- tribble(~COUNTRY, ~candy1, ~candy2, ~candy3,
'US, Canada, and UK', 1.6, 1, 0.8,
'United States',1.67, 1, 1,
'Canada', 2, 0, 1,
'United Kingdom', 1, 2, 0)
into
Candy_Hierarchy <- tribble(~Country, ~Candy, ~Average,
'US, Canada, and UK', 'candy1', 1.6,
'US, Canada, and UK', 'candy2', 1,
'US, Canada, and UK', 'candy3', 0.8,
'United States', 'candy1', 1.67,
'United States', 'candy2', 1,
'United States', 'candy3', 1,
'Canada', 'candy1', 2,
'Canada', 'candy2', 0,
'Canada', 'candy3', 1,
'United Kingdom', 'candy1', 1,
'United Kingdom', 'candy2', 2,
'United Kingdom', 'candy3', 0)
have not receive any error messages as i am not entirely sure how to achieve what i want to do.