I am working to melt
some data using reshape2.
I have a series of tables (about 16), form The Office for National Statistics, merged into one spreadsheet. Each table covers a different type of measurement.
The first table is 16 industries over 6 years for 'Large Businesses.' Where the values are businesses. The second table is also 16 industry over 6 years for 'Medium Businesses.' Where the values are N businesses, and so forth.
I've had some luck Stacking one table using the below:
# install.packages("reshape2")
library(reshape2)
New_Test<- melt(Stack_Test, id.vars = c('Industry'), Var='TotBus' 'Year')
View(New_Test)
The issue is that the new stacked variables are named "Year" or "Totbus". The values are in the correct place, but the headings are not?
My desired output is a data frame with columns like this Industry
, Year
, Large business
, Medium business
, ect. and with the values below in columns.
How can I do this? Is there a resource I can follow along with to learn this slightly better?