<p>As <a href="https://bioinformatics.stackexchange.com/a/2759/48">benn</a> said you can store them in <code>data/</code> subfolder of your package. There is no size limit (AFAIK) but if you plan to publish your package in some repositories they might have limits or other restrictions. Bioconductor requires to divide the data required for a software package at certain threshold, but for small amount of data it is fine. </p>

<p>You can find them via <code>system.file</code> like: <code>read.csv(system.file("data/mydata.csv", package = "mypackage"))</code>.
Of course your bed files will need the apropiate function to load them.  </p>

<p>You can load when your library is called by modifying the <code>local</code> variable, or using <code>.First</code> (I am not so sure of the last one), but this pollutes the environment and sometimes if preferably to use <code>data</code> function. You might need to convert your files to <code>.Rdata</code> file.</p>

CC BY-SA 4.0
2017-11-03T11:48:41.367Z
2019-01-10T08:24:48.057Z
2019-01-10T08:24:48.057Z
llrs
<p>You can store it in <code>data/</code> subfolder. If one of your functions need this bed file, you can include importing it in your function.</p>

<p>Here are some <a href="http://www.davekleinschmidt.com/r-packages/" rel="noreferrer">examples</a> how to get the data from <code>data/</code> subfolder.</p>

<p>There are probably more ways to do this, this is just one way.</p>

CC BY-SA 3.0
2017-11-03T08:33:00.317Z
2017-11-03T08:46:55.437Z
2017-11-03T08:46:55.437Z
benn
<p>I'm currently creating an R package, and my scripts require before any analysis is done that 1-2 bed files be loaded. Normally, I would run the scripts with the following:</p>

<pre><code>library(data.table)
session_bed = read.table("/path/name/to/bedfile.bed")
</code></pre>

<p>and then refer to <code>session_bed</code> throughout the analysis. </p>

<p>However, in order to release this as an R package, I believe that these files must be downloaded at the time on the package installation. </p>

<p>(1) Normally, how are bed files distributed in R packages? Are these gzipped? Where are they placed? </p>

<p>According to <a href="http://r-pkgs.had.co.nz/data.html" rel="noreferrer">http://r-pkgs.had.co.nz/data.html</a>, all .bed files should be <code>inst/extdata</code> I guess. However, it's not clear to me how to "link" to this data within the R package. </p>

<p>How have other packages dealt with this? (Is there a size limit?)</p>

<p>(2) In this case, should the function loading the bed file be executed about loading the R library, <code>library(package_name)</code>? Is there more appropriate option? </p>

<r><bed>
How to release an R package with several bed files?
# How to release an R package with several bed files?

(Asked by: username_0 on 2017-11-03)

I'm currently creating an R package, and my scripts require before any analysis is done that 1-2 bed files be loaded. Normally, I would run the scripts with the following:
library(data.table)
session_bed = read.table("/path/name/to/bedfile.bed")

and then refer to session_bed throughout the analysis. 
However, in order to release this as an R package, I believe that these files must be downloaded at the time on the package installation. 
(1) Normally, how are bed files distributed in R packages? Are these gzipped? Where are they placed? 
According to http://r-pkgs.had.co.nz/data.html, all .bed files should be inst/extdata I guess. However, it's not clear to me how to "link" to this data within the R package. 
How have other packages dealt with this? (Is there a size limit?)
(2) In this case, should the function loading the bed file be executed about loading the R library, library(package_name)? Is there more appropriate option?

**Tags:** r, bed

---

## 2 answers

### Answer by username_2 on 2017-11-03. Score: 7 | Accepted answer

You can store it in `data/` subfolder. If one of your functions need this bed file, you can include importing it in your function.

Here are some [examples](http://www.davekleinschmidt.com/r-packages/) how to get the data from `data/` subfolder.

There are probably more ways to do this, this is just one way.


---

### Answer by username_1 on 2017-11-03. Score: 6

As [benn](https://bioinformatics.stackexchange.com/a/2759/48) said you can store them in `data/` subfolder of your package. There is no size limit (AFAIK) but if you plan to publish your package in some repositories they might have limits or other restrictions. Bioconductor requires to divide the data required for a software package at certain threshold, but for small amount of data it is fine.

You can find them via `system.file` like: `read.csv(system.file("data/mydata.csv", package = "mypackage"))`.
Of course your bed files will need the apropiate function to load them.

You can load when your library is called by modifying the `local` variable, or using `.First` (I am not so sure of the last one), but this pollutes the environment and sometimes if preferably to use `data` function. You might need to convert your files to `.Rdata` file.


---

