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

Backticks in variable names #153

Closed
AmeliaMN opened this issue May 12, 2022 · 3 comments
Closed

Backticks in variable names #153

AmeliaMN opened this issue May 12, 2022 · 3 comments

Comments

@AmeliaMN
Copy link

It's final writeup season! For whatever reason, about 10 of my students have run into this issue this semester, which I had never noticed before. In ggformula graphics, backticks don't seem to work in variable names. As a reprex, consider:

 mtcars <- rename(mtcars, `number of cylinders` = cyl)

If I do things like

lm(mpg~`number of cylinders`, data = mtcars)
mosaic::favstats(`number of cylinders`~vs, data = mtcars)

that all works. But if I try,

> gf_boxplot(`number of cylinders`~vs, data = mtcars)
Error in parse(text = elt) : <text>:1:8: unexpected symbol
1: number of
           ^

I thought it was only happening on one side of the formula, but it's both

> gf_point(mpg~`number of cylinders`, data = mtcars)
Error in parse(text = elt) : <text>:1:8: unexpected symbol
1: number of
           ^

If there's another way to specify variables with spaces in them for ggformula, please let me know!

@rpruim
Copy link

rpruim commented May 12, 2022

This is a duplicate of #152. You can use the github version for now or wait for the next CRAN release (soon, now that grades are in for the term) to get the fix.

@rpruim rpruim closed this as completed May 12, 2022
@rpruim
Copy link

rpruim commented May 12, 2022

In the meantime, a workaround is to using rename() or mutate() to create syntactic names. (But that only works if your students know that sort of recoding.)

@rpruim
Copy link

rpruim commented May 12, 2022

This was a long-standing known issue that I'm glad to have finally fixed. Sorry it got your students at the end of the term. If you or your students install from github, let me know if you encounter an edge cases that don't work.

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

No branches or pull requests

2 participants