Learn R Programming

slopegraph (version 0.1.14)

segmentize: Segmentize an observation-by-period data frame

Description

Convert an observation-by-period data frame into a data frame of line segment coordinates, where each row represents a line segment connecting two time points from the original data.

Usage

segmentize(data, na.span = FALSE, na.omit = TRUE)

Arguments

data

A data frame containing observation-by-period data, where the only columns represent sequentially ordered time period values for each observation. Some values can be missing.

na.span

A logical indicating whether line segments should span periods with missing values. The default is FALSE, such that some segments are not drawn.

na.omit

A logical indicating whether to drop missing observations from the resulting data frame

Value

A five-variable data frame containing: the row from the original data frame, and x1, x2, y1, y2 positions for each segment.

Examples

Run this code
# NOT RUN {
data(gdp)
head(segmentize(gdp))
# }

Run the code above in your browser using DataLab