[R] a question about frame

From: ronggui <0034058_at_fudan.edu.cn>
Date: Thu 16 Jun 2005 - 02:09:05 EST


gg <- function(y) {

         ggg <- function() {
             cat("current frame is", sys.nframe(), "\n")
             cat("parents are", sys.parents(), "\n")
             print(sys.function(0)) # ggg
             print(sys.function(2)) # gg
         }
         if(y > 0) gg(y-1) else ggg()
     }


> gg(3)

current frame is 5
parents are 0 1 2 3 4
function() {

             cat("current frame is", sys.nframe(), "\n")
             cat("parents are", sys.parents(), "\n")
             print(sys.function(0)) # ggg
             print(sys.function(2)) # gg
         }

<environment: 071C62FC>
function(y) {
         ggg <- function() {
             cat("current frame is", sys.nframe(), "\n")
             cat("parents are", sys.parents(), "\n")
             print(sys.function(0)) # ggg
             print(sys.function(2)) # gg
         }
         if(y > 0) gg(y-1) else ggg()
     }


my question is ,why the current frame is 5?why the sys.function is ggg.i am quite confused. anyone can give me some clue?i have read the ?sys.parent,but i still can not get the point exactly.                                  

2005-06-16



Deparment of Sociology
Fudan University

Blog:www.sociology.yculblog.com



R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Received on Thu Jun 16 02:14:42 2005

This archive was generated by hypermail 2.1.8 : Fri 03 Mar 2006 - 03:32:42 EST