Scoping problem when sfApply is used within function (package snowfall - R)

前端 未结 2 1650
误落风尘
误落风尘 2020-12-19 11:57

Let me add another scoping problem in R, this time with the snowfall package. If I define a function in my global environment, and I try to use that one later in an sfApply(

2条回答
  •  鱼传尺愫
    2020-12-19 13:02

    I think you want to sfExport(func1), though I'm not sure if you need to do it in your .GlobalEnv or inside of func2. Hope that helps...

    > y <- matrix(1:10,ncol=2)
    
    > sfExport(list=list("func1"))
    
    > func2(y)
         [,1] [,2]
    [1,]    2    7
    [2,]    3    8
    [3,]    4    9
    [4,]    5   10
    [5,]    6   11
    

提交回复
热议问题