SpaDES (version 1.3.1)

.fileExtensions: File extensions map

Description

How to load various types of files in R.

This function has two roles: 1) to proceed with the loading of files that are in a simList or 2) as a short cut to simInit(inputs = filelist). Generally not to be used by a user.

How to load various types of files in R.

Usage

.fileExtensions()

loadFiles(sim, filelist, ...)

# S4 method for simList,missing loadFiles(sim, filelist, ...)

# S4 method for missing,ANY loadFiles(sim, filelist, ...)

# S4 method for missing,missing loadFiles(sim, filelist, ...)

.saveFileExtensions()

Arguments

sim

simList object.

filelist

list or data.frame to call loadFiles directly from the filelist as described in Details

...

Additional arguments.

See Also

inputs

Examples

Run this code
# NOT RUN {
# Load random maps included with package
filelist <- data.frame(
    files = dir(system.file("maps", package = "SpaDES"),
            full.names = TRUE, pattern = "tif"),
    functions = "rasterToMemory", package = "SpaDES"
)
sim1 <- loadFiles(filelist = filelist)
clearPlot()
if (interactive()) Plot(sim1$DEM)

# Second, more sophisticated. All maps loaded at time = 0, and the last one is reloaded
#  at time = 10 and 20 (via "intervals").
# Also, pass the single argument as a list to all functions...
#  specifically, when add "native = TRUE" as an argument to the raster function
files = dir(system.file("maps", package = "SpaDES"),
            full.names = TRUE, pattern = "tif")
arguments = I(rep(list(native = TRUE), length(files)))
filelist = data.frame(
   files = files,
   functions = "raster::raster",
   objectName = NA,
   arguments = arguments,
   loadTime = 0,
   intervals = c(rep(NA, length(files)-1), 10)
)

sim2 <- loadFiles(filelist = filelist)

# if we extend the end time and continue running, it will load an object scheduled
#  at time = 10, and it will also schedule a new object loading at 20 because
#  interval = 10
end(sim2) <- 20
sim2 <- spades(sim2) # loads the percentPine map 2 more times, once at 10, once at 20
# }

Run the code above in your browser using DataCamp Workspace