Ernest A
Ernest A

Reputation: 7839

Where does data() gets the data set description from?

Calling data without arguments produces a list of available data sets along with a short description of each one, for instance:

!> data()
 Data sets in package ‘datasets’:

 AirPassengers           Monthly Airline Passenger Numbers 1949-1960
 BJsales                 Sales Data with Leading Indicator
 BJsales.lead (BJsales)
                         Sales Data with Leading Indicator
 BOD                     Biochemical Oxygen Demand
 ...

I have written a package that includes some data files in Rda format (made with save()) in the package's data/ directory, and while data() finds them, there's no description.

!> data()
 Data sets in package ‘datasets’:

 AirPassengers           Monthly Airline Passenger Numbers 1949-1960
 BJsales                 Sales Data with Leading Indicator
 BJsales.lead (BJsales)
                         Sales Data with Leading Indicator
 BOD                     Biochemical Oxygen Demand
 ...

 Data sets in package ‘fbdata’:

 football.d1
 football.e0
 ...

How does one include a description for the data sets?

Upvotes: 4

Views: 694

Answers (1)

Ben Bolker
Ben Bolker

Reputation: 226182

Use ?promptData, or the corresponding roxygen2 markup, to generate the skeleton of an Rd file for your data set, then edit it appropriately to add a description, then rebuild the package ...

As @hrbrmaster points out above, if you really want to hack the data description, you can do something like this (example for the plyr package):

datadesc <- file.path(.libPaths()[1],"plyr","Meta","data.rds")
r <- readRDS(datadesc)
r
##      [,1]       [,2]                                                    
## [1,] "baseball" "Yearly batting records for all major league baseball players"
## [2,] "ozone"    "Monthly ozone measurements over Central America."
r[1,2] <- "hacked description"
saveRDS(r,datadesc)

... but I haven't actually tested this.

I don't know what your setup is, but I would argue that in the long run it's actually a lot safer to re-build and re-install the package regularly (wouldn't you like to change the version number so that you can tell easily what version of the data users have access to?) than to hack it in this way ...

Upvotes: 2

Related Questions