0

I am working in R, trying to combine the data from a Sheet in 250 different Excel Files into one data frame. I have put all these files in a list called "Data.Files" and they all contain a sheet named "Selected".

However, not every "Selected" sheet has the same amount of columns and I need to figure out the column count for each so we can do an RBind. I already have the files in a list "Data.Files".

I tried to do df1=read_xlsx(data.files[1], ncol(sheet="Selections"))

But it will not work. Is there a way to do this so it prints out the column count for each file in the list? I am trying to figure out a way to get the Column Count of each Names sheet in the "Data.Files" list so it would print out something like this

Df1=93

Df2=94

etc for all the frames I've pulled from files. Any help is appreciated.

E: Essentially all I would need to do is to export the Global Environment summary as a csv.

Community
  • 1
  • 1
  • "_I need to figure out the column count for each so we can do an RBind_". Is this an XY problem? See [Combine two data frames by rows (rbind) when they have different sets of columns](https://stackoverflow.com/questions/3402371/combine-two-data-frames-by-rows-rbind-when-they-have-different-sets-of-columns) – Henrik Aug 25 '17 at 21:51
  • Consider third-party packages that do not require same number of columns or names like: `plyr::rbind.fill`, `dplyr::bind_rows`, `data.table::rbindlist`... – Parfait Aug 25 '17 at 22:02
  • Thanks @Parfait that worked! The only issue is now I'm getting "Error in as.POSIXct.numeric(what, tz = tzone) : 'origin' must be supplied" It's HR data so there's DOB here that I think is screwing up. Any way to set this for all the data frames? – Carl Gilbertsen Aug 25 '17 at 22:07
  • Theses posts discuss establishing origin for Excel dates: https://stackoverflow.com/questions/15686451/dates-from-excel-to-r-platform-dependency, https://stackoverflow.com/questions/30132645/how-do-i-find-origin-of-a-date-in-r. See if the answers there work for you? – Z.Lin Aug 26 '17 at 03:35

0 Answers0