1

I have a pretty good understanding of C but very little of R. I have installed an R-package (coxme) into R-studio on Windows7 from source which included compiling several C files into a .dll. This package is not standalone and depends on at least 2 other packages (maybe more). It runs too slow so I would like to see if I can speed it up by profiling it first. I used the R-package "profvis" to profile the R-code but it only tells me that 98% of the time get used by the "coxme" package without giving any further details. The call to the R package looks something like:

frail.xg=coxme(Surv(y.vec,delta.vec)~x.mat+g.vec+(1|fiid.vec),varlist=list(K.mat))

The entire package has no function named coxme(...), so I have no idea what goes on after I call this package as shown above. I tagged every function inside the "src" directory of the package to print (append) to a file, but only the init() function fires upon installation when it registers the package. Non of the other functions print to that file once I run coxme from within R-Studio. Besides the init() function it seems that non of the C-functions in the package even get executed when I call coxme(...). My approach is like:

remove.packages("coxme")

manipulate C-code in coxme "src" directory to print to some external file "I am function XYZ, etc.". create coxme.tar.gz

install.packages('E:/Workdir/AOO/R/coxme/coxme.tar.gz', repos = NULL, type="source")
library("coxme")
frail.xg=coxme(Surv(y.vec,delta.vec)~x.mat+g.vec(1|fiid.vec),varlist=list(K.mat))

this produces some expected result. But non of the C-functions seem to get hit, nor does my profiling code. So my questions are:

  1. What exactly gets executed?
  2. How do I go about and find out what's eating up most of the time within the coxme package?
MrFlick
  • 195,160
  • 17
  • 277
  • 295
mschmidt
  • 81
  • 1
  • 2

1 Answers1

0

The main problem is that Rstudio (at least on Windows7) does not update any .dll once it was loaded. So my edits of the C-code never took effect since the old .dll was never replaced, even when I unloaded and recompiled via install.packages(). I had to completely exit Rstudio and manually delete the package directory (coxme). Then restart Rstudio in install from my edited source. Now my edits deliver the desired results.

mschmidt
  • 81
  • 1
  • 2
  • You might try the `More > Clean & Rebuild` option in the `Build` pane to force erasing the `.o`/`.so` objects before reinstalling – MichaelChirico Sep 29 '19 at 15:41
  • Did you success to speed up the `coxme` package ? I'm using it and it takes 3 seconds to get an estimation for 2500 individuals which is too slow for me. I have to bootstrap it. – Flora Grappelli Jan 07 '20 at 10:31