Scoping and functions in R 2.11.1 : What's going wrong?

后端 未结 4 1215
广开言路
广开言路 2020-12-15 07:41

This question comes from a range of other questions that all deal with essentially the same problem. For some strange reason, using a function within another function someti

4条回答
  •  青春惊慌失措
    2020-12-15 08:37

    Well there is no problem in what you posted:

    /tmp$ cat joris.r 
    #!/usr/bin/r -t
    
    some_function <- function(y) y^2
    
    ff <- function(x){
        y <- 4
        some_function(y)  # so we expect 16
    }
    print(ff(3))          # 3 is ignored
    $ ./joris.r 
    [1] 16
    /tmp$
    

    Could you restate and postan actual bug or misfeature?

提交回复
热议问题