ijlyttle / learnr.tidyeval

A learnr tutorial for tidyeval
https://ijlyttle.shinyapps.io/tidyeval
Other
7 stars 2 forks source link

Extra step needed in enquo example? #4

Closed gvwilson closed 2 years ago

gvwilson commented 5 years ago

The last exercise in the "Quosures" section of https://ijlyttle.shinyapps.io/tidyeval/#section-writing-functions-that-use-tidyeval tells me to uncomment an expression that assigns "birth_year" to input_name and then change a function call, presumably so that the variable input_name is passed into filter_sym_value. However, doing this results in a tibble with zero rows rather than the same tibble produced by the original code. Have I misunderstood the instructions? screen shot 2018-11-20 at 12 23 04 pm

ijlyttle commented 5 years ago

Thanks!

I will take it as an action item for me to update the exercise to supply a hint (it took me a couple minutes to wrap my head around this again).

In essence, like earlier in the tutorial, the function argument input_sym is expecting a symbol. As such, my approach would be to convert input_name to a symbol, then evaluate it right away.

Answer filter_sym_value(starwars, !!sym(input_name), 19)
ijlyttle commented 5 years ago

The phrase "so that it uses input_name" should be improved to suggest that it will involve more than replacement.

gvwilson commented 5 years ago

Thanks - I eventually figured out it had to be something like that. This is a really strong tutorial - thank you for creating it.

ijlyttle commented 5 years ago

My pleasure!

ijlyttle commented 2 years ago

Hi Greg - just to note that I have made a new version of the tutorial - aimed at the practical aspects of tidy evaluation, so this issues has been obviated.

Thanks again for your input - when I re-do a more-advanced version, I'll check back in with this issue!