RUnit (version 0.4.32)

inspect: Track the executed code lines of a function or method.

Description

inspect examines and modifies the source code of a function or method. After the modification of the source code, the modified function will be executed and the result of the tracking process will be stored. To store the information a tracker environment with the name track must exist. Note, that not all R code constructs can be handled at the current state. In some cases it is not possible to track a specific code line. Therefore, clearly structured code with consequent use of opening and closing braces to indicate conditional expressions can prevent these parser problems.

Usage

inspect(expr, track = track)

Arguments

expr

Any R function or method call.

track

list object, as returned by a call to tracker.

Author

Thomas König, Klaus Jünemann & Matthias Burger

Details

The return value of inspect is the result returned by the function executed. If the function has no return value nothing is returned either.

See Also

tracker for the call tracking object, and printHTML.trackInfo for displaying results.

Examples

Run this code

## example function
foo <- function(x){
   y <- 0
   for(i in 1:100)
   {
      y <- y + i
   }
   return(y)
}

## the name track is necessary
track <- tracker()

## initialize the tracker
track$init()

## inspect the function
## res will collect the result of calling foo
res <- inspect(foo(10), track = track)

## get the tracked function call info
resTrack <- track$getTrackInfo()

## create HTML sites
printHTML.trackInfo(resTrack)

Run the code above in your browser using DataCamp Workspace