passing ellipsis arguments to map function purrr package, R

后端 未结 3 1678
情歌与酒
情歌与酒 2020-12-19 14:55

I want to use ellipsis parameters inside map function of purrr package. this is a toy example:

f1<-function(x,a=NA,b=NA,prs=seq(0, 1, 0.25),SW=T){
  if(SW         


        
3条回答
  •  独厮守ぢ
    2020-12-19 15:39

    You just need to pass the ellipses through the map_df() call as well. Otherwise they can't get into the inner f1() call.

    f2 <- function(df, ...){
      res <- map_df(colnames(df), ~f1(df[,.], a=., ...), ...)
      return(res)
    }
    

提交回复
热议问题