[R-pkg-devel] Is it possible to reverse engineer a package from the installed library directory ?
Georgi Boshnakov
georgi.boshnakov at manchester.ac.uk
Thu Mar 24 08:43:46 CET 2016
Further to Joshua's comment,
package "Rdpack" has a function reprompt(), which when called with one argument
creates an Rd documentation file. It can do this for methods (S3/S4), classes and package-package if required,
e.g.
library(Rdpack)
reprompt(lm)
creates a lm.Rd in the current working directory.
reprompt() actually checks if the current documentation is up to date and updates the usage statement or adds the items for additional arguments as needed. I use it during development.
Georgi
-----Original Message-----
From: R-package-devel [mailto:r-package-devel-bounces at r-project.org] On Behalf Of Joshua Ulrich
Sent: 24 March 2016 05:53
To: Ben Bolker
Cc: r-package-devel at r-project.org
Subject: Re: [R-pkg-devel] Is it possible to reverse engineer a package from the installed library directory ?
On Wed, Mar 23, 2016 at 9:25 PM, Ben Bolker <bbolker at gmail.com> wrote:
>
> You could take your old install and do this:
>
> library("your_package")
> funs <- ls(pos="package:your_package")
> dump(funs,"your_package.R")
>
> that wouldn't recreate documentation, NAMESPACE files, etc., but it
> would be a start.
>
You might be able to recreate the Rd files using the answers to this StackOverflow question: http://stackoverflow.com/q/7493843/271616
Using the example in my answer as a starting point:
sink(file="survey.Rd")
utils:::.getHelpFile(as.character(help(survey,package="MASS")))
sink()
It might still need some formatting clean-up, but hopefully that gets you 80-90% of the solution.
>
> On 16-03-23 04:43 PM, Paul Hurley wrote:
>>
>> Several years ago I assembled some of my own most used code into a
>> package, and had that installed on my machine. Since then I have
>> lost the source files, but still have the package installed in an old
>> v2.x R installation.
>>
>> I now need to use the package in my current R install, which is v3.1,
>> and won't let me just copy the directory across, as it complains it
>> was build pre v3. Is it possible to reverse engineer a package back
>> to R source files so I can then rebuild it in a new package ?
>>
>> Thanks
>>
>> Paul.
>>
>> --http://www.paulhurley.co.uk
>>
>> [[alternative HTML version deleted]]
>>
>> ______________________________________________
>> R-package-devel at r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-package-devel
>>
>
> ______________________________________________
> R-package-devel at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-package-devel
--
Joshua Ulrich | about.me/joshuaulrich
FOSS Trading | www.fosstrading.com
R/Finance 2016 | www.rinfinance.com
______________________________________________
R-package-devel at r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-package-devel
More information about the R-package-devel
mailing list