I am parsing an excel file with several worksheets and three columns in each worksheet. The three columns have slightly different names in each worksheet (DATE VS Date, etc), so when I execute my code the df data frame has several columns of data. I want to condense df to 3 columns by renaming the headers from each excel sheet. How can I rename the header values when I read in each worksheet?
require(XLConnect)
wb <- loadWorkbook("~/Downloads/BearRiverBand-Rancheria-WindTurbine-Log-2009-2014.xlsx")
lst = readWorksheet(wb, sheet = getSheets(wb))
df <- ldply (lst, data.frame)
I solved my problem:
require(XLConnect)
require(plyr)
wb <- loadWorkbook("~/Downloads/BearRiverBand-Rancheria-WindTurbine-Log-2009-2014.xlsx")
lst = readWorksheet(wb, sheet = getSheets(wb))
dat=data.frame()
for (l in 1:(length(lst)-4)){
s <- data.frame(lst[l])
names(s) <- c('TIME','DATA','BY')
dat <- merge(dat,s,all = TRUE)
}