joshwlambert / DAISIEprep

Extracts phylogenetic island community data from phylogenetic trees
https://joshwlambert.github.io/DAISIEprep
GNU General Public License v3.0
6 stars 3 forks source link

Load files in tutorial - is there a better way? #38

Open luislvalente opened 2 days ago

luislvalente commented 2 days ago

At the moment, the tutorial uses a non-optimal way to locate and load files, e.g.:

plant_phylo <- readRDS(
  file = system.file("extdata", "plant_phylo.rds", package = "DAISIEprep")
)

This might confuse the user. I could not find a good way to do this. Ideally we would directly load a file from the package but without having to use this complicated code.

Neves-P commented 2 days ago

This file is not actually the package (at least under inst/extdata), so this line to me returns

Error in gzfile(file, "rb") : cannot open the connection

It might be easier to include these files as package data, i.e., replacing lines like saveRDS(columbiformes_phylod, file = "inst/extdata/columbiformes_phylod.rds") with usethis::use_data(columbiformes_phylod) in data-raw/columbiformes_phylod.R and then documenting the resulting .rda data object in R/data.R. I'm guessing there is a reason to go with extdata/ instead?

luislvalente commented 2 days ago

thanks @Neves-P ! I didn't realise that the file was not in the package because the render was working fine in my computer (I had forgotten to install the package again locally after the changes). now that has been fixed and the file should be included (in the updt_vignette branch at the moment, waiting for the merge with master)

@joshwlambert - could be worth checking Pedro's suggestions?