[R] Tracking what R actually executes
Ted Harding
Ted.Harding at wlandres.net
Fri Jan 3 01:14:55 CET 2014
On 02-Jan-2014 23:55:28 Duncan Murdoch wrote:
> On 14-01-02 6:05 PM, Fisher Dennis wrote:
>> R 3.0.2
>> All platforms
>>
>> Colleagues
>>
>> This question is probably conceptual rather than technical and I have not
>> thought out all of the issues yet. Lets say I have an extensive list of
>> functions and some lines of code that call the functions. I would like to
>> have a record of all the commands that were actually executed. I realize
> that this could be voluminous but it might be necessary.
>> For example, the code and function might be:
>>
>> ###############
>> INPUT:
>> COUNTER <- function(N)
>> for (i in 1:N) cat(count, i, \n)
>> COUNTER(10)
>>
>> ###############
>> OUTPUT:
>> cat(count, 1, \n)
>> cat(count, 2, \n)
>> cat(count, 3, \n)
>> cat(count, 4, \n)
>> cat(count, 5, \n)
>> cat(count, 6, \n)
>> cat(count, 7, \n)
>> cat(count, 8, \n)
>> cat(count, 9, \n)
>> cat(count, 10, \n)
>>
>> #################
>> If I have formulated the question poorly, please do you best to understand
>> the intent.
>>
>> Dennis
>
> As far as I know, R doesn't have exactly this built in, but the Rprof()
> function gives an approximation. It will interrupt the execution at a
> regular time interval (1/50 sec is the default, I think), and record all
> functions that are currently active on the execution stack. So tiny
> little functions could be missed, but bigger ones probably won't be.
>
> There are also options to Rprof to give other profiling information,
> including more detail on execution position (down to the line number),
> and various measures of memory use.
>
> Duncan Murdoch
Also have a look at
?trace
which you may be able to use for what you want.
Ted.
-------------------------------------------------
E-Mail: (Ted Harding) <Ted.Harding at wlandres.net>
Date: 03-Jan-2014 Time: 00:14:51
This message was sent by XFMail
More information about the R-help
mailing list