[R] R package-building
Prof Brian Ripley
ripley at stats.ox.ac.uk
Thu Jan 10 08:47:56 CET 2002
On Wed, 9 Jan 2002, Tim Hoar wrote:
> Hello,
>
> I am building a package to read in a pretty common atmospheric data format
> and create a SKEW-T, log p diagram (also very common for the atmospheric
> community).
>
> The problem is this: How should one address the (ASCII) data files so that
> the examples find them? I have read through the "Writing R Extensions"
> document and still have a problem.
>
> There seems to be some sort of disconnect between getting the examples
> to run when you "R CMD check <package>" and when you have them installed
> and ready for general consumption.
>
> Before the package is installed (i.e. during the "R CMD check") the
> unix current working directory must be just below the package directory.
>
> The package is going to be called RadioSonde (after the instrument that
> collects the data), and I am building the package under unix.
>
> $cwd/RadioSonde/R/*.R # including getsonde.R
> $cwd/RadioSonde/man/*.Rd
> $cwd/RadioSonde/data/ExampleSonde.txt
>
> $cwd <prompt> R CMD check RadioSonde
> [works fine, I can build]
>
> In order to get the examples to "check" correctly they must be:
>
> profile1 <- getsonde("RadioSonde/data/ExampleSonde.txt")
>
> but then this is inappropriate for the installed version, which
> really should key off the .path.package() ...
>
> > system("pwd")
> /home/thoar
> > .path.package("RadioSonde")
> [1] "/contrib/R-1.3.0/lib/R/library/RadioSonde"
> > ydata <- getsonde("RadioSonde/data/ExampleSonde.txt")
> Error in file(file, "r") : cannot open file `RadioSonde/data/ExampleSonde.txt'
Use data(). Have a file ExampleSonde.R in RadioSonde/data that does
whatever is necessary to read ExampleSonde.txt. Then
data(ExampleSonde) will work, from anywhere.
I think ExampleSonde.R could just contain
ExampleSonde <- getsonde("ExampleSonde.txt")
BTW, assuming ExampleSonde.txt is really data, I suggect you don't give it
a .txt extension. data() allows that for rectangular arrays of data.
See ?data for more details.
--
Brian D. Ripley, ripley at stats.ox.ac.uk
Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/
University of Oxford, Tel: +44 1865 272861 (self)
1 South Parks Road, +44 1865 272860 (secr)
Oxford OX1 3TG, UK Fax: +44 1865 272595
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
More information about the R-help
mailing list