Skip to content

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

@daricomp

Description

@daricomp

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()

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions