[R] Count function calls

Simon Zehnder szehnder at uni-bonn.de
Tue Feb 26 11:53:10 CET 2013

Dear R-users,

I have the following problem: I am running the function 'pvcm' from the 'plm' Panel Data package. Inside this function 'solve' is called and gives for a certain individual data series an exception because of singularity. I would like to know which individual data series causes this error. I tried to debug it, but this is truly painful, as solve is called inside of 'lapply' and there are over 5,000 individual data series in the panel. 

Now, what I would like to do is to count the calls to 'solve' inside the function, so I can see, where the function throws the exception. I tried to use 'trace' with a count variable, but I have no clue how to define a global variable to be used by trace and updated at every call.....is there another approach? 



More information about the R-help mailing list