Skip to contents

Creating and converting aniframe objects

Functions that create an aniframe, coerce other objects to aniframe, or provide example data.

as_aniframe()
Convert a data frame to aniframe
aniframe()
Create an aniframe data frame
example_aniframe()
Create example aniframe data
is_aniframe()
Check if object is an aniframe
ensure_is_aniframe()
Ensure object is an aniframe
validate_aniframe()
Validate an aniframe

Creating and converting anievent objects

Functions that create an anievent (long-format behavioural event records) or coerce other objects to anievent.

to_anievent()
Encode per-frame data into an anievent
as_anievent()
Cast a data frame to an anievent
anievent()
Create an anievent data frame
is_anievent()
Check if object is an anievent
ensure_is_anievent()
Ensure object is an anievent
validate_anievent()
Validate an anievent

Metadata handling

Functions for reading, setting, and retrieving the metadata attached to aniframe or anievent objects.

get_metadata()
Get metadata
set_metadata()
Set metadata
get_unit_time()
The unit the index or bout boundaries are in
set_unit_time()
Set the temporal unit of an aniframe or anievent
get_unit_space()
The unit the spatial coordinates are in
set_unit_space()
Set the spatial unit of an aniframe object
get_unit_angle()
The unit the angular axes are in
set_unit_angle()
Set the angular unit of an aniframe object
get_sampling_rate()
The sampling rate, in Hz
set_sampling_rate()
Set the sampling rate of an aniframe or anievent
get_sampling_interval()
The interval between consecutive observations
is_sampling_regular()
Is the frame regularly sampled?
get_axis_directions()
Get the direction each axis points
set_axis_directions()
Say which way an axis points
get_axis_extents()
Get how far each axis runs
set_axis_extents()
Say how far each axis runs
get_angle_direction()
Which way angles run
set_angle_direction()
Say which way angles run
get_handedness()
Whether the frame is right- or left-handed
set_handedness()
Say whether the frame is right- or left-handed
list_default_metadata()
Default metadata structure

Declaring variables

Declare which columns carry identity, time and position. These are the frame’s structure rather than a description of it, so the setters restructure the frame to match — coercing column types, relocating, reordering, regrouping, and refreshing derived fields. set_metadata() refuses these fields for that reason.

get_variables_what() get_variables_when() get_variables_where() set_variables_what() set_variables_when() set_variables_where() add_variables_what() add_variables_when() add_variables_where() remove_variables_what() remove_variables_when() remove_variables_where()
Declare which columns carry identity, time and position
get_variables_event() set_variables_event() add_variables_event() remove_variables_event()
Declare which columns carry per-frame event labels
get_index()
The column an aniframe is indexed by
set_index()
Declare which column an aniframe is indexed by
get_axes()
The axis roles of an aniframe, and the columns carrying them
set_axes()
Declare which column carries which axis role
get_coordinate_system()
The coordinate system an aniframe is in

Connections

Manage connections between identity or temporal variables (e.g. skeleton edges between keypoints, or social-network edges between individuals). Stored as a named list of from/to tibbles in metadata$connections.

set_connections()
Set the connections for a variable
get_connections()
Get connections from an aniframe
add_connections()
Add connections to an aniframe
remove_connections()
Remove connections from an aniframe

Spatial checks

These functions provide checks for your coordinate system. is_spatial() and ensure_is_spatial() check that the columns named in variables_where are present and numeric; the is_cartesian*() family reports which coordinate system the frame is in, which follows from the axis roles it declares.

is_spatial()
Test whether the spatial columns match the metadata
ensure_is_spatial()
Ensure the spatial columns match the metadata
is_cartesian()
Test whether an aniframe uses a Cartesian coordinate system
is_cartesian_1d()
Test for a 1-D Cartesian coordinate system
is_cartesian_2d()
Test for a 2-D Cartesian coordinate system
is_cartesian_3d()
Test for a 3-D Cartesian coordinate system
is_polar()
Test whether an aniframe uses a polar coordinate system
is_cylindrical()
Test whether an aniframe uses a cylindrical coordinate system
is_spherical()
Test whether an aniframe uses a spherical coordinate system
ensure_is_cartesian()
Internal guard for Cartesian checks
ensure_is_cartesian_1d()
Internal guard for 1-D Cartesian checks
ensure_is_cartesian_2d()
Internal guard for 2-D Cartesian checks
ensure_is_cartesian_3d()
Internal guard for 3-D Cartesian checks
ensure_is_polar()
Internal guard for polar checks
ensure_is_cylindrical()
Internal guard for cylindrical checks
ensure_is_spherical()
Internal guard for spherical checks

Helpers

rad_to_deg()
Convert radians to degrees
deg_to_rad()
Convert degrees to radians
wrap_angle()
Constrain angles to a standard range
unwrap_angle()
Remove wrapping from a sequence of angles
convert_nan_to_na()
Convert NaN to NA in numeric columns