I have the following data frame.
sample_data <- data.frame(Date = c ("2017-01-31", "2017-01-31","2017-02-28", "2017-01-31", "2017-03-31","2017-02-28", "2017-03-31", "2017-04-30", "2017-02-28","2017-03-31","2017-04-30","2017-04-30"),
stock = c("c", "a", "a", "b", "a", "b", "b", "a", "c", "c", "b", "c"),
Price = c(9,6,7,8,10,12,13, 11, 17, 12, 13, 14))
I am looking to rearrange this so that the stock letter are assigned to a column instead of all being in the second column. So the data frame would only show four dates and 4 prices for every stock (stock "a" would be one column, "b" the next etc etc).