boxuancui / DataExplorer

Automate Data Exploration and Treatment
http://boxuancui.github.io/DataExplorer/
Other
513 stars 88 forks source link

Possible failure to escape variable names #81

Closed rodzam closed 6 years ago

rodzam commented 6 years ago

Issue: DataExplorer does not properly escape variable names when given as a string in an argument.

Example:

df1 <- tibble(population=c(10,20,30,40,50), `poverty-rate`=c(50,40,30,20,10), `pct-hisp`=c(.2,.5,.3,.2,.6))
plot_scatterplot(df1, by="poverty-rate")

Error:

Error in FUN(X[[i]], ...) : object 'poverty' not found

I expect it's a simple issue where the function isn't properly escaping the variable name (e.g., `poverty-rate`). As an aside, I'd agree that it's bad practice to include mathematical operators in the variable name but sometimes an external dataset will use that nomenclature so we must work with it.

boxuancui commented 6 years ago

Working with irregular names is not easy, and creates a lot of potential problems. End users should supply appropriate names because it is so much easier to do so. E.g.,

names(df1) <- make.names(names(df1))
plot_scatterplot(df1, by = "poverty.rate")

As a result, I am closing this.