0
$\begingroup$

I have 10s of spreadsheets with facility-level rows. Each spreadsheet corresponds to a month. They each contain approximately the same variables (10s of them), but often with different column naming and categorical variable coding schemes. I want to combine them into a single table with facility-month-level rows. Are there any pre-existing tools that are well-suited to this problem?

I'm sort of imagining an R or Python or Stata package that lets me specify a list of lists of column names that all mean the same thing, and a dictionary of variable coding schemes, and then handles the merge while spitting out a summary table highlighting any variables that weren't found in at last one spreadsheet.

$\endgroup$

1 Answer 1

1
$\begingroup$

Not a complete solution, but in R:

as_tibble(iris) %>% rename(foo = any_of(c("Petal.Length", "OtherName", "OtherOtherName")))

will rename to foo anything that's in that vector of variable names.

h/t Robert On

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.