Object not found error with ddply inside a function

后端 未结 5 716
别跟我提以往
别跟我提以往 2020-11-30 01:58

This has really challenged my ability to debug R code.

I want to use ddply() to apply the same functions to different columns that are sequentially nam

5条回答
  •  野趣味
    野趣味 (楼主)
    2020-11-30 02:21

    Today's solution to this question is to make summarize into here(summarize). e.g.

    myFunction <- function(x, y){
        NewColName = "a"
        z = ddply(x, y, here(summarize),
                Ave = mean(eval(parse(text=NewColName)), na.rm=TRUE)
        )
        return(z)
    }
    

    here(f), added to plyr in Dec 2012, captures the current context.

提交回复
热议问题