From h.wickham at gmail.com  Fri Jan 17 15:35:54 2014
From: h.wickham at gmail.com (Hadley Wickham)
Date: Fri, 17 Jan 2014 08:35:54 -0600
Subject: [Rd] How to debug an R package (with C code)
In-Reply-To: <CAJoaRhbeSJ9oLL5mPNOrZ59qbesz=RG0B8qDrnMQMvR8FrTVkg@mail.gmail.com>
References: <e6b8123fd4af42d78ce33ce3fee50851@SIXPR01MB224.apcprd01.prod.exchangelabs.com>
	<CAGSjAUCK1kTfpRKnuj6f4dieiFysqd4vOWJOSqkyzETr2uMkAg@mail.gmail.com>
	<CADwqtCOVoP_okamqtRdfMNc-rE7VwE5gqAC1oM1+q5D0ULBqyg@mail.gmail.com>
	<CAJoaRhbeSJ9oLL5mPNOrZ59qbesz=RG0B8qDrnMQMvR8FrTVkg@mail.gmail.com>
Message-ID: <CABdHhvGNGPTKRd5jY8BH8ZAnYHDwD7drayjoirNCGvcLuN4ePw@mail.gmail.com>

>> Even if you are using a developer mode, sourcing an R file will have no
>> effect on a) the shared object library (DLL/so/dylib) available in the R
>> session, nor which shared objects are associated with the package. There
>> are ways to unload shared libraries within an R session, but personally I
>> tend to avoid them. The best way of being absolutely sure that the right
>> shared library is getting used is to reinstall the package, then close the
>> R session and restart.
>
> I value having a short turnaround time in debugging over such absolute
> surety, so I would recommend using load_all from Hadley's devtools
> package, which is usually able to recompile and reload the library
> without restarting R. I think the OP indicated that they are using
> RStudio, which should have a way to drive devtools (still, "source"
> would be the wrong command.)

In Rstudio, devtools::load_all() is bound to Cmd + shift + L. Rstudio
also provides Build and reload, which builds the package, restarts R
and reloads it.  This is a little slower than load_all(), but also a
little more accurate so can come in handy from time-to-time.

Hadley

-- 
http://had.co.nz/



[Rd] How to debug an R package (with C code)
Hadley Wickham