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

Let across.() supports functions with namepsace #511

Closed
psychelzh opened this issue Jun 24, 2022 · 2 comments · Fixed by #512
Closed

Let across.() supports functions with namepsace #511

psychelzh opened this issue Jun 24, 2022 · 2 comments · Fixed by #512
Labels
bug Something isn't working

Comments

@psychelzh
Copy link

psychelzh commented Jun 24, 2022

If the .fns contains namespace, it will throw an error.

data.frame(x = 1) |> 
    tidytable::mutate.(tidytable::across.(.fns = forcats::as_factor))
#> Error in `fn_to_expr()`:
#> ! .fns needs to be a list, function name, or formula
data.frame(x = 1) |> 
    dplyr::mutate(dplyr::across(.fns = forcats::as_factor))
#>   x
#> 1 1

Created on 2022-06-24 by the reprex package (v2.0.1)

@psychelzh
Copy link
Author

But weiredly, rlang::as_function works for this case:

rlang::as_function(forcats::as_factor)
#> function (x, ...) 
#> {
#>     ellipsis::check_dots_used()
#>     UseMethod("as_factor")
#> }
#> <bytecode: 0x0000019ed1d42db8>
#> <environment: namespace:forcats>

Created on 2022-06-24 by the reprex package (v2.0.1)

@markfairbanks
Copy link
Owner

All fixed! Thanks for catching this.

data.frame(x = 1) |> 
    tidytable::mutate.(tidytable::across.(.fns = forcats::as_factor))
#> # A tidytable: 1 × 1
#>   x    
#>   <fct>
#> 1 1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants