Hi I'm trying to build a code that tries to do the following:
- lists all the files in a folder
- extracts the data from each of the excel files (each excel file has multiple sheets and I am using
XLConnect
package to pull the data from different sheets) - reshape the data into the format that works best for my data analysis
Here is my code
for (i in 1:n) {
wb <- loadWorkbook(filelist[i])
assign(paste("field",i,"_reportcontents",sep = ""),
readWorksheet(wb, sheet="Report Contents"))
assign(paste("field",i,"_company",sep=""),
paste("field",i,"_reportcontents[31,3]",sep = ""))
}
The way the above code is set up, the second variable, which is field[i]_company is being set as the string "fieldi_reportcontents[31,3]" rather than the value that is in the dataframe field[i]_reportcontents.
How can I fix the code to achieve the values in the data frame rather than allocation of a string?