pad_frames: Pad the end of list of data frames

Description Usage Arguments Details Value Examples

View source: R/functions.R

Description

Use recycling to pad the end of a list of data frames where data frame elements in the list repeat in a cyclical pattern.

Usage

1
pad_frames(x, id, n.period = 360, rotation = "add", force = TRUE)

Arguments

x

list of data frames.

id

character, column name referring to column of x representing frame sequence integer IDs.

n.period

An integer, the known period of rotation that will be part of an animation in which the map data frames in x will be sequentially plotted over. Default is 360 (1-degree increment rotations).

rotation

character, one of "add" or "pad".

force

When the length of x is greater than or equal to n.period still force padding to occur. Defaults to TRUE. Otherwise return x.

Details

pad_frames is used on lists of data frames where sequence of data frames contains content that repeats over the list. It is used in cases where the data frames contain map data (long, lat, and z), for example describing the visible hemisphere surface of a rotating globe. The number of iterations in a full rotation may not be factorable by the length of the time series of map data (length of list). For example, a rotating globe animation may complete 10 rotations with 60 frames per rotation, using 600 frames total, but the list x may contain 550 data frames. With rotation="pad", the last data frame in x is recycled to pad the series out to 600 frames so that the animation can display and "hang" on the terminal map data set until a final complete rotation is completed. With rotation="add", a full period is added to the end of the x rather than padding only far enough to make the length of the data series factorable by the rotation period length.

Value

returns x but padded with it's final element appended repeatedly based on a specified period and type of padding method.

Examples

1
2
3
4
5
6
7
library(dplyr)
library(purrr)
data(annualtemps)
x <- map(1:4, ~mutate(filter(annualtemps, Year-2009==.x), idx=.x))
n <- 6
pad_frames(x, id="idx", n.period=n, rotation="add")
pad_frames(x, id="idx", n.period=n, rotation="pad")

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