0

I am trying to create a subset of a data frame I've created and am getting what appears to be a common error "...undefined columns selected...". Most solutions suggest a simple misplaced error but I believe my code is correct.

I've tested different combinations of variables in the subset and it's clear it's the last three variables creating the issues. Analysis has shown there are no NAs in the fields They're all fields within a larger list called SOURCE_DATA. I'm looking for any suggestion as to why I might be receiving this error. The link below is to a photo of the Data and Values descriptions in RStudio.

Data - Variables

DATA_SUBSET <- SOURCE_DATA[,unique(c(IDVars, InterventionVar, OutcomeVars, ControlVars, ConditionalVars))]

Error in `[.data.frame`(SOURCE_DATA, , unique(c(IDVars, InterventionVar,  : 
  undefined columns selected
zx8754
  • 52,746
  • 12
  • 114
  • 209
  • For each of your variable-name vectors, e.g. `IDVars`, do this and make sure you get all TRUEs: `IDVars %in% names(SOURCE_DATA)`. – DanY Oct 15 '21 at 16:53
  • 1
    [See here](https://stackoverflow.com/q/5963269/5325862) on making a reproducible example that is easier for folks to help with. Without any of your data, we have no way of knowing whether all those names are accurately the names of columns in that data frame – camille Oct 15 '21 at 17:12
  • DanY - thank you that helped me narrow down the error (missing underscores in three items). – Craven1082 Oct 15 '21 at 17:27

0 Answers0