Closed xiaoyingpu closed 4 years ago
is this a case where if someone is using factor()
in the spec they should actually be converting the variable ahead of time before running it through ggplot?
Yeah theoretically but I do stuff like this all the time especially when I need to map factors to colors
ggplot(mtcars, aes(x = factor(cyl), y = mpg, fill = factor(cyl)) + geom_col()
Sure, but a simple rewrite is something like:
mtcars %>%
mutate(cyl = factor(cyl)) %>%
ggplot(aes(x = cyl, y = mpg, fill = cyl)) +
geom_col()
Then you only have to do the conversion once?
On the other hand, you could allow arbitrary expressions but evaluate them first, and then label them according to the expression converted into a string and use that string to match variables (e.g. when making sure a probability expression is grounded properly / verifying it multiplies to a joint). So you wouldn't have to special-case the factor()
function (or any other function), but people would be able to include arbitrary expressions as long as they used the same expression everywhere.
This should be taken care of now
Well PR #81 broke this bit
Somewhere around https://github.com/MUCollective/pgog/blame/parser_fixes/R/parse.R#L294