Passing arguments to iterated function through apply

后端 未结 3 692
深忆病人
深忆病人 2020-12-13 18:18

I have a function like this dummy-one:

FUN <- function(x, parameter){
  if (parameter == 1){
      z <- DO SOMETHING WITH \"x\"}
  if (parameter ==2){
         


        
3条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-13 18:50

    You want apply(data,1,FUN,parameter=1). Note the ... in the function definition:

    > args(apply)
    function (X, MARGIN, FUN, ...) 
    NULL
    

    and the corresponding entry in the documentation:

    ...: optional arguments to ‘FUN’.

提交回复
热议问题