From cboettig at gmail.com  Mon Aug  4 18:38:37 2014
From: cboettig at gmail.com (Carl Boettiger)
Date: Mon, 4 Aug 2014 09:38:37 -0700
Subject: [Rd] Preferred way to include internal data in package?
In-Reply-To: <CABtg=K=42Sz0xWU56+LSWsC0zTa+fxK6brd2PLQ9qS6RJrwiYw@mail.gmail.com>
References: <6445D029-9700-4ACA-ABF8-79335461F260@imperial.ac.uk>
	<CABFfbXvZK-p-ob2Lzea0Zoeh3vogMkDkooyhKHbWc61wYbHdSA@mail.gmail.com>
	<6EAB4931-0C1C-4D51-AC4D-C5086785E47D@imperial.ac.uk>
	<CABtg=K=42Sz0xWU56+LSWsC0zTa+fxK6brd2PLQ9qS6RJrwiYw@mail.gmail.com>
Message-ID: <CAN_1p9x_KEd_eUtTwDJo+CAMP1keqNiiqK6w6mkmU9MSDXhWMg@mail.gmail.com>

I would think that putting them in an appropriate subdirectory in inst
might be preferable, e.g. inst/examples, and then reading the data in
with ?system.file where necessary?

(I have frequently been instructed that data ought not be mixed with
code, as it makes both code and data harder to read, maintain, or
reuse.  On the other hand, if there's a good reason to avoid
system.file for this, I'd be happy to be enlightened so that I too
could improve my practices).

Cheers,

Carl

On Mon, Aug 4, 2014 at 9:23 AM, G?bor Cs?rdi <csardi.gabor at gmail.com> wrote:
> If you want to keep it as text, then you can just put it in the code:
>
> mydata <-
> '"","mpg","cyl","disp","hp","drat","wt","qsec","vs","am","gear","carb"
> "Mazda RX4",21,6,160,110,3.9,2.62,16.46,0,1,4,4
> "Mazda RX4 Wag",21,6,160,110,3.9,2.875,17.02,0,1,4,4
> "Datsun 710",22.8,4,108,93,3.85,2.32,18.61,1,1,4,1
> '
>
> and then you can read from it via text connections:
>
> read.csv(textConnection(mydata))
>
> Gabor
>
> On Mon, Aug 4, 2014 at 12:11 PM, Keirstead, James E
> <j.keirstead at imperial.ac.uk> wrote:
>> I saw that, but actually I was wondering if there was a more general method.  I?d like to use plain text files if I can, instead of Rda files, since they?re easier to maintain (and it?s a small file).
>>
>> On 4 Aug 2014, at 16:30, Jeroen Ooms <jeroen.ooms at stat.ucla.edu> wrote:
>>
>>>> I?m developing a package and would like to include some data sets for internal use only, e.g. configuration parameters for functions.  What is the preferred way of doing this?  If I put them in data/, then R CMD check asks me to document them but I?d prefer it if they floated beneath the surface, without the users awareness.
>>>
>>> Perhaps in sysdata.rda. See "Writing R Extensions".
>>
>> ______________________________________________
>> R-devel at r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-devel
>
> ______________________________________________
> R-devel at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel



-- 
Carl Boettiger
UC Santa Cruz
http://carlboettiger.info/



[Rd] Preferred way to include internal data in package?
Carl Boettiger