pal_events: Construct a validated dyadic-event table

View source: R/events.R

pal_eventsR Documentation

Construct a validated dyadic-event table

Description

pal_events() builds the core data object used throughout palsr: a table of dyadic interaction events, each involving two actors at a known time and location. Projected Actor Locations are computed from these histories.

Usage

pal_events(
  data,
  actor1 = "actor1",
  actor2 = "actor2",
  time = "time",
  lon = "lon",
  lat = "lat",
  drop_self = TRUE
)

Arguments

data

A data.frame with one row per dyadic event.

actor1, actor2

Column names (length-1 character) identifying the two actors involved in each event. The pair is treated as unordered.

time

Column name of the event time. Must be a Date, or coercible to one via as.Date().

lon, lat

Column names of the event longitude and latitude, in decimal degrees.

drop_self

Logical; drop events whose two actors are identical (default TRUE).

Details

Longitudes must lie in ⁠[-180, 180]⁠ and latitudes in ⁠[-90, 90]⁠. Rows with missing actor, time, or coordinate values are dropped with a message.

Value

An object of class pal_events (a data.frame subclass) with canonical columns actor1, actor2, time, lon, lat, sorted by time.

Examples

df <- data.frame(
  from = c("A", "A", "B"),
  to   = c("B", "C", "C"),
  when = as.Date(c("2001-01-01", "2001-06-01", "2002-01-01")),
  x    = c(7.1, 8.0, 7.5),
  y    = c(9.0, 9.4, 10.1)
)
ev <- pal_events(df, actor1 = "from", actor2 = "to",
                 time = "when", lon = "x", lat = "y")
ev


palsr documentation built on July 1, 2026, 5:07 p.m.