Closed hrj21 closed 3 years ago
Just a simple reminder about library vs require https://yihui.org/en/2014/07/library-vs-require/
@hrj21 Thanks for spotting that. I've fixed the function up and pushed the changes to development
branch.
@SamGG Thanks for the recommendation. We will need to revisit the way in which the dependencies are loaded and installed by the user. It may be an idea to simply install and load them up as users are using the relevant functions. Something like what is recommended here: https://statsandr.com/blog/an-efficient-way-to-install-and-load-r-packages/
@ghar1821 Thanks for the link. The "More efficient way" is sufficient to me as it does not rely on other packages. While using installed.packages() sounds great for finding out packages to install, I don't think it is useful to load and test required packages. For example, https://github.com/ImmuneDynamics/Spectre/blob/742ebc4bc09ce69b970eceb78291bdbf5229d20d/R/read.files.R#L36 should be as simple as
library(Spectre)
or
if (!require('Spectre')) stop('Spectre is required but not installed')
@hrj21 Sorry for diverging from your issue.
@hrj21 Thanks for spotting that. I've fixed the function up and pushed the changes to
development
branch.@SamGG Thanks for the recommendation. We will need to revisit the way in which the dependencies are loaded and installed by the user. It may be an idea to simply install and load them up as users are using the relevant functions. Something like what is recommended here: https://statsandr.com/blog/an-efficient-way-to-install-and-load-r-packages/
I can confirm this now works 👯♂️
Hi all, me again (only because I love your package so much ;) ).
The
do.extract()
function seems to internally look for the objectspatial.dat
in the environment, rather than honouring thedat
argument to the function. This is fine if we name our spatial objectspatial.dat
as in the tutorial, but I don't think this is intended behaviour. I've copied the function code below. The following lines seem problematic and should havedat
instead ofspatial.dat
I think (or just change the name of the argument tospatial.dat
):roi.stack <- spatial.dat[[roi]]$RASTERS
roi.poly <- spatial.dat[[roi]]$MASKS[[mask]]$polygons
other.polys <- names(spatial.dat[[roi]]$MASKS)
ply <- spatial.dat[[roi]]$MASKS[[ply.name]]$polygons
spatial.dat[[roi]]$DATA[[name]] <- roi.dat
return(spatial.dat)