You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Adding an extra call to a ggplot() call results in an obscure code suggestion: I expected ggplot() where you called +. For example, this learnr exercise
###
__Edit your code from the previous exercise so that `marital` appears in order of increasing frequency.__ Use a forcats function to change the order.
```{r fct_rev, exercise = TRUE}
gss_cat %>%
ggplot(aes(marital)) +
geom_bar()
```
```{r fct_rev-solution}
gss_cat %>%
ggplot(aes(fct_rev(fct_infreq(marital)))) +
geom_bar()
```
```{r fct_rev-check}
grade_this_code()
```
Returns the message below when a student supplies the code
Since adding an extra line to a ggplot() call is a common failure mode for ggplot2, we should find a way to provide a better code suggestion.
One idea: perhaps the ggcheck package can come with a ggplot2 specific version of grade_this_code()that can begin by assuming it is working with ggplot2 code, e.g. grade_this_ggplot_code()
The text was updated successfully, but these errors were encountered:
I think we should be able to fix this in gradethis. The underlying problem is that we don't do a good job of handling the case when there are more operations than expected:
# Extra addition
code_feedback("a + b + c", "a + c")
#> I didn't expect `+` where you wrote `a + b + c`.# Extra addition, plus pipe (smaller reprex of the ggplot example)
code_feedback("x %>% a() + b + c", "a(x) + c")
#> In `x %>% a() + b + c`, I expected you to call `a()` where you called `+`.# Extra pipes
code_feedback("x %>% a() %>% b() %>% c()", "x %>% a() %>% c()")
#> In `x %>% a() %>% b() %>% c()`, I expected you to call `a()` where you called `b()`.
We have an open issue for the extra pipe case: #185
Adding an extra call to a
ggplot()
call results in an obscure code suggestion:I expected ggplot() where you called +
. For example, this learnr exerciseReturns the message below when a student supplies the code
Since adding an extra line to a
ggplot()
call is a common failure mode for ggplot2, we should find a way to provide a better code suggestion.One idea: perhaps the ggcheck package can come with a ggplot2 specific version of
grade_this_code()
that can begin by assuming it is working with ggplot2 code, e.g.grade_this_ggplot_code()
The text was updated successfully, but these errors were encountered: