Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Renaming variables while importing makes the output code unusable (comes with suggestion for solution) #265

Open
daricomp opened this issue Feb 29, 2024 · 1 comment

Comments

@daricomp
Copy link

daricomp commented Feb 29, 2024

Hi,

using esquisser() and then the GUI for Import and Update, the renaming of the column variables makes the output code not reusable, because the renamed columns do not correspond anymore to the original column names.

Example if I rename Sepal.Length in the iris dataset into Sepal.Lenght2, this is esquisse's output code:

ggplot(iris) +
aes(x = Sepal.Length2) +
geom_histogram(bins = 30L, fill = "#112446") +
theme_minimal()

This code cannot work because in the environment the column is still iris$Sepal.Length.

Now, one solution would be to make the esquisse Import function use tidyverse before the ggplot command to do the renaming. Exemple of always working output code:

iris %>%
rename(Sepal.Length2 = Sepal.Length) %>%
ggplot() +
aes(x = Sepal.Length2) +
geom_histogram(bins = 30L, fill = "#112446") +
theme_minimal()

Of course, the filter commands written by the esquisse Data tab (which already follow the syntax suggested here) should be placed after the rename command. Example:

iris %>%
rename(Sepal.Length2 = Sepal.Length) %>%
filter(Sepal.Length2 > 1) %>%
ggplot() +
aes(x = Sepal.Length2) +
geom_histogram(bins = 30L, fill = "#112446") +
theme_minimal()

@pvictor
Copy link
Member

pvictor commented Mar 7, 2024

Yes this is problematic, we need to see how we can generate code in this module.
There some work to be done, I cannot say when I'll get time to look at that.

Victor

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants