Using rlist on a list of imported Excel sheets causes problems when filtering on certain names

56 views Asked by At

I have dug into rlist and purrr and found them to be quite helpful in working with lists of pre-structured data. I tried to solve the problems arising on my one to improve my coding skills - so thanks to the community of helping out! However, I reached a dead-end now:

I want to write a code which is needed to be written in a way, that we throw our excel files in xlsm format to the folder an r does the rest.

I Import my data using:

vec.files<-list.files(pattern=".xlsm")
vec.numbers<- gsub("\\.xlsm","",vec.files)

list.alldata <- lapply(vec.files, read_excel, sheet="XYZ")
names(list.alldata) <- vec.numbers

The data we call is a combination of charaters, Dates (...).

When I try to use the rlist-package everything works fine until I try to use to filter on names, which were in the excel file not a fixed entry (e.g. Measurable 1), but a reference to another field (e.g. =Table1!A1, or an Reference).

If I try to call a false element I get this failure:

list.map(list.alldata, NameWhichWasAReferenceToAnotherFieldBefore)

Fehler in eval(.expr, .evalwith(.data), environment()) : 
  Objekt 'Namewhichwasareferencetoanotherfieldbefore' nicht gefunden

I am quite surprised, as if I call

names(list.alldata[[1]])

I get a vector with the correct entries / names.

As I identified the read_excel() as the problem causing reason I tried to add col_names=True, but did not help. Also col_names=False calls the correct arguments into the dataset.

I assume, that exporting the data as a .csv would help, but this is not an option. Can this be easily done by r in a pree-loop?

In my concept of working assessing the data by the names is essential and there is no work around so I really appreciate your help!

0

There are 0 answers