Split column name and convert data from wide to long format in R
问题 I have a large dataset that I need to convert to long format from wide format. That should be simple enough and there are lots of examples of how to do that on this forum. However, in this case, I also need to split the column headers used in the wide format and create a column for each of them in the long format. Example dataset data <- data.frame("East2010"=1:3, "West2010"=4:6, "East2011"=7:9, "West2011"=5:7) data East.2010 West.2010 East.2011 West.2011 1 1 4 7 5 2 2 5 8 6 3 3 6 9 7 What I