save_seq: Save a sequence of still images to disk

Description Usage Arguments Details Value Examples

View source: R/functions.R

Description

Save a sequence of still images to disk with a single function call and data frame.

Usage

1
save_seq(data, style = "map", use_mclapply = FALSE, mc.cores = 1L, ...)

Arguments

data

a data frame containing networks, tiles, lines or polygons information.

style

character, must be style="map" for maps (uses save_map) or style="tsline" for time series line graphs (uses save_ts).

use_mclapply

TRUE for parallel processing. Must be FALSE (default) for non-Unix-alikes (e.g., Windows systems).

mc.cores

integer, the number of CPU cores requested for parallel processing, passed to mclapply.

...

additional arguments passed to save_map or save_ts.

Details

save_seq is a convenient wrapper function for save_map and save_ts. It provides some moderate generality and abstraction by moving the most proximal aspects of data preparation inside the function, i.e., breaking a data frame into a list of data frame subsets by plot ID and passing each explicitly to iterative calls to either save_map or save_ts. The option for parallel processing on Linux systems (by forking with parallel::mclapply) is also part of save_seq. Using mclapply was chosen for convenience and may be changed in a future package version.

It does not save much in the way of gross typing, but calling a single wrapper function, passing mostly the same arguments, and not having to explicitly call save_map or save_ts withing the context of map or walk calls is arguably cleaner, simpler, and less complex for some use cases.

The additional arguments ... passed to save_map or save_ts are required, not optional. Any call to save_seq will consist mostly of these arguments. It is best to first make sure you can successfully call save_map and save_ts directly. Then try this wrapper function. See the intoductory vignette for details: browseVignettes(package="mapmate").

Value

usually returns NULL after writing files to disk. May optionally return a list of ggplot objects with or without the file writing side effect.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
## Not run: 
library(dplyr)
library(purrr)
data(annualtemps)
temps <- mutate(annualtemps, frameID = Year - min(Year) + 1) %>%
  group_by(Year, frameID) %>% summarise(z=mean(z))
xlm <- range(temps$Year)
ylm <- range(temps$z)

# should specify a dir or set working dir for file output
# consider running over a smaller subset of frame IDs
save_seq(temps, style="tsline", x="Year", y="z", id="frameID",
  col="blue", xlm=xlm, ylm=ylm)

## End(Not run)

leonawicz/mapmate documentation built on May 21, 2019, 5:09 a.m.