Open chendaniely opened 5 years ago
Another error with +:
Here's a reprex as this stands now. @garrettgman do you have any suggestions for the messages we wish to see?
pkgload::load_all("~/work/gradethis")
#> Loading gradethis (a8f772102d5b51c2ff3810d45fb4f532f94d8a72)
code_feedback("sqrt(1)", "sqrt(1 + 2)")
#> In `sqrt(1)`, I expected `+` where you wrote `1`.
code_feedback("0 + sqrt(log(2))", "sqrt(log(2))")
#> I expected you to call `sqrt()` where you called `+`.
For infix operators , I think we need to say "something +
something" instead of +
. For example, the feedback message below
Suggests to a new user that they should do this, which leads them to a frustrating dead end that they may not be able to see their way out of:
A better message would be "In flipper_length_mm
> bill_length_mm
, I expected something *
something where you wrote bill_length_mm
." Alternatively, we could replace +
with "a call to +
()" in our messages, but new R users will have trouble interpreting that.
This replacement should generalize to all infix operators.
Should I open this as a separate issue? Its not clear to me what the thrust of Daniel's issue was.
Here's another example.
```{r starwars-setup}
library(dplyr)
starwars %>%
transmute(
mass = as.integer(mass * 2.205),
height = as.integer(height / 2.54)
)
starwars %>%
transmute(
height = height / 2.54,
mass = mass * 2.205
)
grade_this_table(check_column_order = TRUE)
> Your table’s columns were not in the expected order. The first 2 columns of your table should be `height` and `mass`.
>
> I expected you to call `height = /` where you called `height = as.integer()`. Give it another try.
given:
returns