Skip to content
Prev 31359 / 63424 Next

Why is srcref of length 6 and not 4 ?

Duncan Murdoch wrote:
Thank you Duncan,

I am using this to massage the output of "parse" into a data frame to 
represent it as a tree
(see http://addictedtor.free.fr/misc/sidekick.png)

 > cat( readLines( "/tmp/test.R" ), sep = "\n" )
f <- function( x, y = 2 ){
        z <- x + y
        g <- function( x ){
          print( x )
          xx <- x + 1
        }
        g( x )
}
 >
 > sidekick( "/tmp/test.R", encoding = "utf-8" )
  id parent     mode srcref1 srcref2 srcref3 srcref4               
description
1  1      0 function       1       1       8       1 f <- function(x, y 
= 2) {
2  2      1     name       1      26       1      
26                         {
3  3      1     call       2       2       2      11                z <- 
x + y
4  4      1 function       3       2       6       2        g <- 
function(x) {
5  5      1     call       7       2       7       
7                      g(x)
6  6      4     name       3      20       3      
20                         {
7  7      4     call       4       4       4      13                  
print(x)
8  8      4     call       5       4       5      14               xx <- 
x + 1