[R] function problem: multi selection in one argument

Bert Gunter bgunter@4567 @end|ng |rom gm@||@com
Tue Jan 25 01:40:09 CET 2022

RStudio is **not** R. In particular, the so-called TidyVerse consists
of all *non*-standard contributed packages, about which the Posting
Guide (linked below) says:

"For questions about functions in standard packages distributed with R
(see the FAQ Add-on packages in R), ask questions on R-help.
[The link is:
This gives the list of current _standard_ packages]

If the question relates to a contributed package , e.g., one
downloaded from CRAN, try contacting the package maintainer first. You
can also use find("functionname") and
packageDescription("packagename") to find this information. Only send
such questions to R-help or R-devel if you get no reply or need
further assistance. This applies to both requests for help and to bug

Note that RStudio maintains its own help resources at:
This is where questions about the TidyVerse, ggplot, etc. should be posted.

Bert Gunter

"The trouble with having an open mind is that people keep coming along
and sticking things into it."
-- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )

On Mon, Jan 24, 2022 at 4:14 PM Kai Yang via R-help
<r-help using r-project.org> wrote:
> Hello Team,
> I can run the function below:
> library(tidyverse)
> f2 <- function(indata, subgrp1){
>   indata0 <- indata
>   temp    <- indata0 %>% select({{subgrp1}}) %>% arrange({{subgrp1}}) %>%
>     group_by({{subgrp1}}) %>%
>     mutate(numbering =row_number(), max=max(numbering))
>   view(temp)
>   f_table <- table(temp$Species)
>   view(f_table)
>   return(f_table)
> }
> f2(iris, Species)
> You can see the second argument I use Species only, and it works fine.
> But If I say, I want the 2nd argument = Petal.Width, Species , how should I write the argument? I did try f2(iris, c(Petal.Width, Species)), but I got error message:
> Error: arrange() failed at implicit mutate() step.
> * Problem with `mutate()` column `..1`.
> i `..1 = c(Petal.Width, Species)`.
> i `..1` must be size 150 or 1, not 300.
> I'm not sure how to fix the problem either in function or can fix it when using the function.
> Thank you,
> Kai
>         [[alternative HTML version deleted]]
> ______________________________________________
> R-help using r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

More information about the R-help mailing list