animate: Animate a pixel map

View source: R/animate.R

animateR Documentation

Animate a pixel map

Description

This function animates a pixel map created with build_pmap so that the pixels ficker between a series of sampled values.

Usage

animate(pmap, flickerSpeed = 0.05, aniLength)

Arguments

pmap

An object from build_pmap.

flickerSpeed

A numeric value between 0 and 0.5.

aniLength

An integer. A larger value corresponds with a longer animation; a value of at least 20 is recommended.

Examples

## Not run: 
# This code demonstrates how to animate a pixel map
# It is not run here.
data(us_geo)
ca_geo <- subset(us_geo, us_geo@data$STATE == "06")
pix <- pixelate(ca_geo, id = "region")

data(us_data)
us_data$GEO.id2 <- as.numeric(us_data$GEO.id2)
ca_data <- subset(us_data, us_data$GEO.id2 > 6000 & us_data$GEO.id2 < 7000)
ca_data <- read.uv(data = ca_data, estimate = "pov_rate", error = "pov_moe")
row.names(ca_data) <- seq(1, nrow(ca_data), 1)

df <- data.frame(region = sapply(slot(ca_geo, "polygons"),
 function(x) slot(x, "ID")), name = unique(ca_geo@data$GEO_ID))
ca_data$region <- df[match(ca_data$GEO_ID, df$name), 1]
ca_data$region <- as.character(ca_data$region)

m <- build_pmap(data = ca_data, distribution = "uniform", pixelGeo = pix, id = "region")

a <- animate(m, aniLength = 25)
view(a)

## End(Not run)

pkuhnert/VizU documentation built on March 19, 2024, 10:51 p.m.