I have the below data frame. I was wondering, what is the best way to make this tidy so I can plot using ggplot2. I've tried using the gather() function in R, to do something like this:
tidy_cost <- gather(cost, key = 'Utility', value = 'unit', -c(Date, `Gas price`, `Electricity price`))
then:
tidy_cost <- gather(tidy_cost, key = 'Price', value = 'GBP', -c(Date, Utility, unit))
but what the above does is dublicate everything as for some cells there is a missmatch between 'Utility' and 'Price'....see table 2. Any advice would be greately appreciated. Thanks.


code to reproduce sample of original data frame :
structure(list(Date = structure(c(18686, 18714, 18745, 18775,
18806), class = "Date"), `Gas usage` = c(0, 125, 104, 98, 43),
`Gas price` = c(0, 45.46, 39.67, 38.32, 19.18), `Electricity usage` = c(0,
208, 232, 226, 166), `Electricity price` = c(0, 37.82, 43.09,
42.98, 32.2)), row.names = c(NA, -5L), class = c("tbl_df",
"tbl", "data.frame"))