diff --git a/docs/pkgdown.yml b/docs/pkgdown.yml index 9c75c88..74712ef 100644 --- a/docs/pkgdown.yml +++ b/docs/pkgdown.yml @@ -8,7 +8,7 @@ articles: link2GI4: link2GI4.html link2GI5: link2GI5.html link2GI6: link2GI6.html -last_built: 2024-06-14T05:36Z +last_built: 2024-06-14T06:58Z urls: reference: https://r-spatial.github.io/link2GI/reference article: https://r-spatial.github.io/link2GI/articles diff --git a/inst/templates/advancedSpatial.brew b/inst/templates/advancedSpatial.brew index ae6eaa6..e5ebb2f 100644 --- a/inst/templates/advancedSpatial.brew +++ b/inst/templates/advancedSpatial.brew @@ -12,28 +12,24 @@ <% } %> -# append additional packages if defined by calling script -if (exists("appendlibs") && appendlibs[[1]] != "") -{ - libs = append(<%=deparse(libs)%>,<%=deparse(appendlibs)%>) -} else { -libs = <%=deparse(libs)%> -} - - -# Now create/read root direcory, folder structure and load packages +# create/read root direcory, folder structure and load packages # NOTE root_folder MUST be defined in calling script if (!exists("root_folder")) { stop("variable root_folder is NOT defined, You must define a root folder!") } -# call central function +# append additional paths if defined by calling script +dirs = append(<%=deparse(dirs)%>,appendpaths) + + +# append additional packages if defined by calling script +libs = append(<%=deparse(libs)%>,appendlibs) + # call central function dirs = link2GI::setupProj(root_folder = root_folder, - folders = <%=deparse(dirs)%>, + folders = dirs, fcts_folder = <%=deparse(code_subfolder)%>) - # Define more variables # Load more data diff --git a/inst/templates/base.brew b/inst/templates/base.brew index b7f077b..05a7f8a 100644 --- a/inst/templates/base.brew +++ b/inst/templates/base.brew @@ -12,26 +12,22 @@ <% } %> -# append additional packages if defined by calling script -if (exists("appendlibs") && appendlibs[[1]] != "") -{ - libs = append(<%=deparse(libs)%>,<%=deparse(appendlibs)%>) -} else { -libs = <%=deparse(libs)%> -} - - -# Now create/read root direcory, folder structure and load packages +# create/read root direcory, folder structure and load packages # NOTE root_folder MUST be defined in calling script if (!exists("root_folder")) { stop("variable root_folder is NOT defined, You must define a root folder!") } +# append additional paths if defined by calling script +dirs = append(<%=deparse(dirs)%>,appendpaths) + + +# append additional packages if defined by calling script +libs = append(<%=deparse(libs)%>,appendlibs) -# call central function # call central function dirs = link2GI::setupProj(root_folder = root_folder, - folders = <%=deparse(dirs)%>, + folders = dirs, fcts_folder = <%=deparse(code_subfolder)%>) diff --git a/inst/templates/baseSpatial.brew b/inst/templates/baseSpatial.brew index 4041939..288fb4d 100644 --- a/inst/templates/baseSpatial.brew +++ b/inst/templates/baseSpatial.brew @@ -11,29 +11,22 @@ # This script is sourced when you run the main control script. Use variable dirs to access project directories. - -# append additional packages if defined by calling script - -# append additional packages if defined by calling script -if (exists("appendlibs") && appendlibs[[1]] != "") -{ - libs = append(<%=deparse(libs)%>,<%=deparse(appendlibs)%>) -} else { -libs = <%=deparse(libs)%> -} - - -# Now create/read root direcory, folder structure and load packages +# create/read root direcory, folder structure and load packages # NOTE root_folder MUST be defined in calling script if (!exists("root_folder")) { stop("variable root_folder is NOT defined, You must define a root folder!") } +# append additional paths if defined by calling script +dirs = append(<%=deparse(dirs)%>,appendpaths) +# append additional packages if defined by calling script +libs = append(<%=deparse(libs)%>,appendlibs) + # call central function dirs = link2GI::setupProj(root_folder = root_folder, - folders = <%=deparse(dirs)%>, + folders = dirs, fcts_folder = <%=deparse(code_subfolder)%>) # Define more variables diff --git a/inst/templates/config-default-projects.yml b/inst/templates/config-default-projects.yml index ff8eb08..983536f 100644 --- a/inst/templates/config-default-projects.yml +++ b/inst/templates/config-default-projects.yml @@ -17,7 +17,7 @@ baseSpatial: init_git: true init_renv: true global: false - libs: ["terra", "stars", "sf" , "RStoolbox", "tmap" , "mapview", "dplyr"] + libs: ["terra", "stars", "sf" , "RStoolbox", "tmap" , "mapview", "dplyr", "CAST", "link2GI"] create_folders: true files: [ "src/pre-processing.R", "src/post-processing.R", "src/processing.R", "src/functions/000_setup.R" ,"src/main-control.R"] advancedSpatial: @@ -28,7 +28,7 @@ advancedSpatial: init_git: true init_renv: true global: false - libs: ["terra", "stars", "sf" , "RStoolbox", "tmap" , "mapview" ,"dplyr", "caret" ,"randomforest"] + libs: ["terra", "stars", "sf" , "RStoolbox", "tmap" , "mapview" ,"dplyr", "caret" ,"randomforest", "CAST", "link2GI"] create_folders: true files: [ "src/pre-processing.R", "src/post-processing.R", "src/processing.R", "src/functions/000_setup.R" ,"src/main-control.R"] diff --git a/inst/templates/script_control.brew b/inst/templates/script_control.brew index 5fe7c1b..4f9aeca 100644 --- a/inst/templates/script_control.brew +++ b/inst/templates/script_control.brew @@ -14,8 +14,13 @@ require(yaml) root_folder <- find_rstudio_root_file() # Read master configuration -config_master <- read_yaml(file = file.path(root_folder, "src/configs/config-master.yml")) +config_master = read_yaml(file = file.path(root_folder, "src/configs/config-master.yml")) +# additional packages to load appendlibs = "" +# additional paths to init +appendpaths = "" + +# setup the environment source(file.path(root_folder, "src/functions/000_setup.R")) diff --git a/inst/templates/script_setup.brew b/inst/templates/script_setup.brew index f6a812b..39b0679 100644 --- a/inst/templates/script_setup.brew +++ b/inst/templates/script_setup.brew @@ -13,17 +13,24 @@ <% } %> require(link2GI) -# Define libraries - -# Load libraries and create environment object to be used in other scripts for path navigation -project_folders <- list.dirs(path = root_folder, full.names = FALSE, recursive = TRUE) -project_folders <- project_folders[!grepl("\\..", project_folders)] -dirs <- setupProj( - root_folder = root_folder, - fcts_folder = file.path(root_folder, "src/functions/"), - folders = project_folders, - libs = libs, - create_folders = FALSE) +# create/read root direcory, folder structure and load packages +# NOTE root_folder MUST be defined in calling script +if (!exists("root_folder")) { + stop("variable root_folder is NOT defined, You must define a root folder!") +} + +# append additional paths if defined by calling script +dirs = append(<%=deparse(dirs)%>,appendpaths) + + +# append additional packages if defined by calling script +libs = append(<%=deparse(libs)%>,appendlibs) + +# call central function +dirs = link2GI::setupProj(root_folder = root_folder, + folders = folders>, + fcts_folder = <%=deparse(code_subfolder)%>) + # Define more variables