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@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.

Reply via email to