I have my company's marketing expense report in Excel, with five tabs - each representing the line item expenses for each of the last five years and identical columns. I'm trying to automate/script the restructure of the file into one dataframe with the additional variable "year", so I can analyze it in Tableau without using a join.
Is it possible to read an xlsx file in R and rbind() the tabs somehow? I'm currently reading in the tabs as separate .csv files, which is just as labor-intensive as restructuring manually in Excel. Here's what I have (except with many more tabs):
data1<- read.csv("tab1.csv") #This year
data1$year <- c(1:nrow(data1))
data1$year <- 2016
data2<- read.csv("tab2.csv") #Last year
data2$year <- c(1:nrow(data2))
data2$year <- 2015
data3<- read.csv("tab3.csv") #Two years ago
data3$year <- c(1:nrow(data32))
data3$year <- 2014
data <- rbind(data1, data2, data3)
rm(data1,data2,data3)