[R] R package-building

Tim Hoar thoar at cgd.ucar.edu
Thu Jan 10 18:54:17 CET 2002


Sorry to all those who responded, but I am not getting my point across.
I have read the "Writing R Extensions" document and DO have the
suggested directory structure, and I have the data files in the
data directory. One data file is really an .RData file, one _cannot_ be.
I am even having trouble with the .RData data file.

Most of the confusion is that people are giving me suggestions that
work when the package is already installed and R knows about the
package PATH (for lack of a better concept). My problem is that
during the "check" sequence, the existing R PATH does _not_ contain
the data to be data()'d or load()'d, EVEN THOUGH the data IS
IN the <package>/data directory  (or so it seems to me).



to wit (from within R):

> system("pwd")
/home/thoar/R
> system("ls -l")
total 10
drwxr-xr-x   5 thoar    cgdcas       512 Jan  9 16:44 RadioSonde
> system("ls -lR RadioSonde")
RadioSonde:
total 10
-rw-r--r--   1 thoar    cgdcas       750 Jan  9 16:32 DESCRIPTION
-rw-r--r--   1 thoar    cgdcas       758 Jan  9 16:44 INDEX
drwxr-xr-x   2 thoar    cgdcas       512 Jan  9 14:20 R
drwxr-xr-x   2 thoar    cgdcas       512 Jan  9 16:44 data
drwxr-xr-x   2 thoar    cgdcas       512 Jan  4 16:43 man

RadioSonde/R:
total 106
-rw-r--r--   1 thoar    cgdcas      2433 Jan  9 11:54 getsonde.R
-rw-r--r--   1 thoar    cgdcas       701 Jan  9 14:13 plot.wind.R
-rw-r--r--   1 thoar    cgdcas      2115 Jan  9 14:10 plotsonde.R
-rw-r--r--   1 thoar    cgdcas       439 Jan  4 16:43 satlft.R
-rw-r--r--   1 thoar    cgdcas     11171 Jan  9 14:17 skewt.axis.R
-rw-r--r--   1 thoar    cgdcas     21188 Jan  4 16:43 skewt.data.R
-rw-r--r--   1 thoar    cgdcas       146 Jan  4 16:43 skewt.lines.R
-rw-r--r--   1 thoar    cgdcas       116 Jan  4 16:43 skewt.points.R
-rw-r--r--   1 thoar    cgdcas       251 Jan  4 16:43 skewtx.R
-rw-r--r--   1 thoar    cgdcas       212 Jan  4 16:43 skewty.R
-rw-r--r--   1 thoar    cgdcas      4346 Jan  9 10:40 station.symbol.R
-rw-r--r--   1 thoar    cgdcas      3977 Jan  4 16:43 wobf.R

RadioSonde/data:
total 256
-rw-r--r--   1 thoar    cgdcas       179 Jan  9 16:44 00Index
-rw-r--r--   1 thoar    cgdcas     63216 Jan  4 16:43 ExampleSonde.txt
-rw-r--r--   1 thoar    cgdcas     65718 Jan  9 13:19 sample.sonde.RData

RadioSonde/man:
total 58
-rw-r--r--   1 thoar    cgdcas      5222 Jan 10 09:05 ExampleSonde.Rd
-rw-r--r--   1 thoar    cgdcas       372 Jan  9 12:29 RadioSonde-internal.Rd
-rw-r--r--   1 thoar    cgdcas      4294 Jan 10 09:05 getsonde.Rd
-rw-r--r--   1 thoar    cgdcas      1775 Jan 10 09:03 plot.wind.Rd
-rw-r--r--   1 thoar    cgdcas      2710 Jan 10 09:06 plotsonde.Rd
-rw-r--r--   1 thoar    cgdcas      2383 Jan  9 15:33 sample.sonde.Rd
-rw-r--r--   1 thoar    cgdcas      2680 Jan 10 09:06 skewt.axis.Rd
-rw-r--r--   1 thoar    cgdcas      1175 Jan 10 09:24 skewt.lines.Rd
-rw-r--r--   1 thoar    cgdcas      1157 Jan 10 09:24 skewt.points.Rd
-rw-r--r--   1 thoar    cgdcas      1873 Jan 10 09:24 station.symbol.Rd
> data("ExampleSonde.txt")
Warning message:
Data set `ExampleSonde.txt' not found in: data("ExampleSonde.txt")
> data("sample.sonde.RData")
Warning message:
Data set `sample.sonde.RData' not found in: data("sample.sonde.RData")


#  PLEASE NOTE: There exists no "RadioSonde" package at this point! All
#  the pieces are there, but thats about it.
#  sample.sonde.Rdata  was created  by save(<yadda>,<yadda>,ascii=TRUE)
#  When I use a different LOAD:

> load("RadioSonde/data/sample.sonde.RData")
>

# R does EXACTLY as expected! However, this is clearly not an appropriate
# example once the package is installed!


# I have commented out all my examples save one:

\examples{
   load("sample.sonde.RData")
}

When I try to "check" it, it bombs:

0[230]2 sunray2:~/R > R CMD check RadioSonde
* checking for working latex ... OK
* using log directory `/home/thoar/R/RadioSonde.Rcheck'

Installing source package `RadioSonde' ...
 R
 data
 help
 >>> Building/Updating help pages for package `RadioSonde'
     Formats: text html latex example
  ExampleSonde                      text    html    latex   example
  RadioSonde-internal               text    html    latex
  getsonde                          text    html    latex   example
  plot.wind                         text    html    latex   example
  plotsonde                         text    html    latex   example
  sample.sonde                      text    html    latex
  skewt.axis                        text    html    latex   example
  skewt.lines                       text    html    latex   example
  skewt.points                      text    html    latex   example
  station.symbol                    text    html    latex   example
 DONE (RadioSonde)

DONE (INSTALL)

* checking for file `RadioSonde/DESCRIPTION' ... OK
* checking package directory ... OK
* checking for sufficient file permissions ... OK
* checking DESCRIPTION Package field ... OK
* checking DESCRIPTION Version field ... OK
* checking DESCRIPTION License field ... OK
* checking DESCRIPTION Description field ... OK
* checking DESCRIPTION Title field ... OK
* checking DESCRIPTION Author field ... OK
* checking DESCRIPTION Maintainer field ... OK
* checking R files for library.dynam ... OK
* checking Rd files ... OK
* checking for undocumented objects ... OK
* checking for code/documentation mismatches ... OK
* creating RadioSonde-Ex.R ... OK
* checking examples ... ERROR
* running examples failed
1[231]2 sunray2:~/R >

I don't see how, BEFORE THE PACKAGE IS BUILT, the "data", "load", or any
other command should know to search for any "data" directories in all
directories in the current working directory. Naturally, once the package
is installed, this is not a problem. At the CHECK stage, however, there
is no .lib.loc information available for a package that does not exist.

What am I not understanding about the PATH strategy for R?
Perhaps I am not building/checking the package in the intended fashion?

I can send a TAR file of the package (~54kb) to any interested parties.

Sincerely, and I appreciate the help -- Tim

P.S.  The intended [real world] data files are the result of a data
      collection mechanism beyond my control and contain an aggregation of
      metadata in a header and a subsequent table. They have an unknown
      number of lines of "text", a unique line of text, what amounts to
      the col.names, a garbage line of text, and then the table of data.
      Seems to me the .txt extension is the best descriptor for this.
      All my getsonde() function does is scan() the file in as a series
      of lines, parse the lines and decodes the number of lines to skip
      for read.table(). Along the way I grab the col.names and convert
      to lower case, and the presence of the garbage line in-between
      the col.names and the data prevents a straightforward call to
      read.table.

      Some of my examples SHOULD show how to read a real radiosonde
      datafile, not a preprocessed R dataset. So, I really need to
      have     sample.sonde <- getsonde("ExampleSonde.txt")   as
      a valid example. Simply getting   data("contrived")    to
      work is insufficient, I think.


<The rest of this is in response to Brian Ripley's reply>

> 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


Hunh?   RadioSonde/R/getsonde.R   is the function that reads in
        RadioSonde/data/ExampleSonde.txt.   Are you telling me to
copy/move   RadioSonde/R/getsonde.R       to
       RadioSonde/data/ExampleSonde.R ?

I'm sorry, but I really don't understand.

Tim

## Tim Hoar, Associate Scientist              email: thoar at ucar.edu     ##
## Geophysical Statistics Project             phone: 303-497-1708       ##
## National Center for Atmospheric Research   FAX  : 303-497-1333       ##
## Boulder, CO  80307                    http://www.cgd.ucar.edu/~thoar ##

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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