| Title: | An R package providing core data structures for movement data |
|---|---|
| Description: | An R package providing core data structures for movement data. |
| Authors: | Mikkel Roald-Arbøl [aut, cre] (ORCID: <https://orcid.org/0000-0002-9998-0058>) |
| Maintainer: | Mikkel Roald-Arbøl <[email protected]> |
| License: | MIT + file LICENSE |
| Version: | 0.5.0 |
| Built: | 2026-06-03 06:50:47 UTC |
| Source: | https://github.com/animovement/aniframe |
Subset aniframe with [
## S3 method for class 'aniframe' x[i, j, ..., drop = FALSE]## S3 method for class 'aniframe' x[i, j, ..., drop = FALSE]
x |
An aniframe object |
i |
Row indices |
j |
Column indices |
... |
Additional arguments |
drop |
If TRUE, simplify to vector when possible |
A subset aniframe
Extract single column from aniframe with [[
## S3 method for class 'aniframe' x[[i, ...]]## S3 method for class 'aniframe' x[[i, ...]]
x |
An aniframe object |
i |
Column index or name |
... |
Additional arguments |
A vector or data frame
Column assignment for aniframe with [[<-
## S3 replacement method for class 'aniframe' x[[i, ...]] <- value## S3 replacement method for class 'aniframe' x[[i, ...]] <- value
x |
An aniframe object |
i |
Column index or name |
... |
Additional arguments |
value |
Replacement value |
Modified aniframe
Subset assignment for aniframe with [<-
## S3 replacement method for class 'aniframe' x[i, j, ...] <- value## S3 replacement method for class 'aniframe' x[i, j, ...] <- value
x |
An aniframe object |
i |
Row indices |
j |
Column indices |
... |
Additional arguments |
value |
Replacement values |
Modified aniframe
Extract column from aniframe with $
## S3 method for class 'aniframe' x$name## S3 method for class 'aniframe' x$name
x |
An aniframe object |
name |
Column name |
A vector
Column assignment for aniframe with $<-
## S3 replacement method for class 'aniframe' x$name <- value## S3 replacement method for class 'aniframe' x$name <- value
x |
An aniframe object |
name |
Column name |
value |
Replacement value |
Modified aniframe
Append one or more from/to pairs to the existing connections for a
variable. from and to may be either single strings or character vectors
of equal length (one connection per element).
add_connections(data, from, to, variable = "keypoint")add_connections(data, from, to, variable = "keypoint")
data |
An aniframe object. |
from |
Character vector of source endpoints. |
to |
Character vector of target endpoints. Must be the same length
as |
variable |
Character scalar. Name of the variable the connections
relate to (must be in |
No deduplication is performed — duplicates of an existing pair will appear
twice in the resulting table. Endpoints not found in data[[variable]]
produce a warning but are still appended.
The aniframe with the new connections appended.
set_connections(), get_connections(), remove_connections()
## Not run: data <- example_aniframe() data <- add_connections(data, from = "head", to = "neck") data <- add_connections( data, from = c("neck", "neck"), to = c("shoulder_right", "shoulder_left") ) ## End(Not run)## Not run: data <- example_aniframe() data <- add_connections(data, from = "head", to = "neck") data <- add_connections( data, from = c("neck", "neck"), to = c("shoulder_right", "shoulder_left") ) ## End(Not run)
Arrange rows of an aniframe
## S3 method for class 'aniframe' arrange(.data, ..., .by_group = FALSE)## S3 method for class 'aniframe' arrange(.data, ..., .by_group = FALSE)
.data |
An aniframe object |
... |
Variables to order by |
.by_group |
If TRUE, arrange within groups |
An arranged aniframe
Convert a data frame to aniframe
as_aniframe( data, metadata = list(), variables_what = NULL, variables_when = NULL, variables_where = NULL )as_aniframe( data, metadata = list(), variables_what = NULL, variables_when = NULL, variables_where = NULL )
data |
A data frame with movement data. |
metadata |
A list of metadata to attach to the aniframe. |
variables_what |
Character vector of identity columns that together
define a unique entity. Defaults to |
variables_when |
Character vector of temporal columns that together
define a unique timepoint. Defaults to |
variables_where |
Character vector of spatial columns that together define position. If NULL, detected from data. |
An aniframe object
Convert aniframe to regular data frame
## S3 method for class 'aniframe' as.data.frame(x, ...)## S3 method for class 'aniframe' as.data.frame(x, ...)
x |
An aniframe object |
... |
Additional arguments |
A regular data frame
Replaces all NaN values with NA in numeric columns of a data frame.
convert_nan_to_na(data)convert_nan_to_na(data)
data |
A data frame. |
A data frame with NaN values replaced by NA in numeric columns.
Returns a list containing the default metadata fields and their initial
values for an aniframe object. Most fields are initialized as NA and
should be set appropriately for your data.
default_metadata()default_metadata()
A named list with the following fields:
source: Data source identifier (character, NA)
source_version: Version of the data source (character, NA)
filename: Original filename(s) (character vector, NA). Accepts a
vector of length 1 or more — readers that load from multiple files
(e.g. aniread::read_trackball()) populate this with all source paths.
sampling_rate: Sampling rate in Hz (numeric, NA)
start_datetime: Start date and time of recording (POSIXct, NA)
reference_frame: Reference frame (factor, "allocentric")
coordinate_system: Coordinate system (factor, "cartesian")
origin: Location of the (0,0) coordinate relative to the recording
frame (factor, "bottom_left"). Permitted values: "bottom_left", "top_left".
y_height: Height of the recording frame in y-axis units (numeric, NA).
Used by set_origin() to reflect y coordinates when switching origin
conventions.
connections: Named list of connection tables, one per identity or
temporal variable (typically keypoint for skeletons; could also be
individual for social networks). Each entry is a 2-column tibble of
from/to pairs. Default is an empty list. Manage via
set_connections(), get_connections(), add_connections() and
remove_connections().
set_metadata(), get_metadata()
Convert degrees to radians
deg_to_rad(x)deg_to_rad(x)
x |
Numeric vector of angles (degrees). |
Numeric vector of angles expressed in radians.
Ensure object is an aniframe
ensure_is_aniframe(x)ensure_is_aniframe(x)
x |
An object to test |
Error if not an aniframe
Stops with a clear error message if data is not Cartesian.
ensure_is_cartesian(data)ensure_is_cartesian(data)
data |
A data frame. |
Internal guard for 1‑D Cartesian checks
ensure_is_cartesian_1d(data)ensure_is_cartesian_1d(data)
data |
A data frame. |
Internal guard for 2‑D Cartesian checks
ensure_is_cartesian_2d(data)ensure_is_cartesian_2d(data)
data |
A data frame. |
Internal guard for 3‑D Cartesian checks
ensure_is_cartesian_3d(data)ensure_is_cartesian_3d(data)
data |
A data frame. |
Internal guard for cylindrical checks
ensure_is_cylindrical(data)ensure_is_cylindrical(data)
data |
A data frame. |
Internal guard for polar checks
ensure_is_polar(data)ensure_is_polar(data)
data |
A data frame. |
Internal guard for spherical checks
ensure_is_spherical(data)ensure_is_spherical(data)
data |
A data frame. |
Generates a synthetic aniframe object with random coordinates for testing and demonstration purposes. The function creates a complete design with all combinations of time points, individuals, keypoints, trials, and sessions.
example_aniframe( n_obs = 50, n_individuals = 3, n_keypoints = 11, n_trials = 1, n_sessions = 1, n_dims = 2 )example_aniframe( n_obs = 50, n_individuals = 3, n_keypoints = 11, n_trials = 1, n_sessions = 1, n_dims = 2 )
n_obs |
Integer. Number of time observations per combination. Default is 50. |
n_individuals |
Integer. Number of individuals to simulate. Default is 3. |
n_keypoints |
Integer. Number of keypoints per individual (max 11). Default is 11. When set to 1, only "centroid" is used. Otherwise, anatomical keypoints are used (head, neck, shoulders, etc.). |
n_trials |
Integer. Number of trials per session. Default is 1. |
n_sessions |
Integer. Number of sessions. Default is 1. |
n_dims |
Integer. Number of spatial dimensions (1, 2, or 3). Default is 2. If 1, only x coordinates are generated. If 2, x and y coordinates are generated. If 3, x, y, and z coordinates are generated. |
An aniframe object containing randomly generated tracking data with
columns for individual, keypoint, time, trial, session, and spatial coordinates
(x, y, and/or z depending on n_dims). The coordinates are drawn from a
standard normal distribution.
# Create a basic example with default parameters (2D) example_aniframe() # Create a 1D example example_aniframe(n_dims = 1) # Create a 3D example example_aniframe(n_dims = 3) # Create a smaller example with 2 individuals and 5 keypoints example_aniframe(n_individuals = 2, n_keypoints = 5) # Create example with multiple trials and sessions example_aniframe(n_obs = 100, n_trials = 3, n_sessions = 2) # Create minimal example with just centroid in 3D example_aniframe(n_keypoints = 1, n_dims = 3)# Create a basic example with default parameters (2D) example_aniframe() # Create a 1D example example_aniframe(n_dims = 1) # Create a 3D example example_aniframe(n_dims = 3) # Create a smaller example with 2 individuals and 5 keypoints example_aniframe(n_individuals = 2, n_keypoints = 5) # Create example with multiple trials and sessions example_aniframe(n_obs = 100, n_trials = 3, n_sessions = 2) # Create minimal example with just centroid in 3D example_aniframe(n_keypoints = 1, n_dims = 3)
Filter rows of an aniframe
## S3 method for class 'aniframe' filter(.data, ..., .preserve = FALSE)## S3 method for class 'aniframe' filter(.data, ..., .preserve = FALSE)
.data |
An aniframe object |
... |
Logical predicates |
.preserve |
Keep group structure |
A filtered aniframe
Read the connections currently stored on an aniframe. Returns the full
named list of from/to tibbles by default, or a single tibble when
variable is supplied.
get_connections(data, variable = NULL)get_connections(data, variable = NULL)
data |
An aniframe object. |
variable |
Optional character scalar. When |
A named list of tibbles (when variable is NULL), or a single
2-column tibble.
set_connections(), add_connections(), remove_connections()
Get metadata
get_metadata(data, fields = NULL)get_metadata(data, fields = NULL)
data |
aniframe |
fields |
If only specific metadata fields should be returned. |
the metadata associated with the aniframe
Group an aniframe
## S3 method for class 'aniframe' group_by(.data, ...)## S3 method for class 'aniframe' group_by(.data, ...)
.data |
An aniframe object |
... |
Variables to group by |
A grouped aniframe
Check if object is an aniframe
is_aniframe(x)is_aniframe(x)
x |
An object to test |
Logical: TRUE if x inherits from aniframe
Returns TRUE if the data frame satisfies any of the 1‑D, 2‑D or 3‑D
Cartesian checks defined in the helper functions.
is_cartesian(data)is_cartesian(data)
data |
A data frame. |
Logical scalar.
The data frame must contain exactly one of x, y or z and none of the
polar columns (rho, phi, theta).
is_cartesian_1d(data, stop = FALSE)is_cartesian_1d(data, stop = FALSE)
data |
A data frame. |
stop |
Unused placeholder kept for API compatibility. |
Logical scalar (invisible).
Requires columns x and y. Column z may be present only if it is
completely NA.
is_cartesian_2d(data)is_cartesian_2d(data)
data |
A data frame. |
Logical scalar (invisible).
Requires non‑missing columns x, y and z.
is_cartesian_3d(data)is_cartesian_3d(data)
data |
A data frame. |
Logical scalar (invisible).
Requires rho, phi and z; forbids theta.
is_cylindrical(data)is_cylindrical(data)
data |
A data frame. |
Logical scalar.
Requires columns rho and phi and forbids theta or z.
is_polar(data)is_polar(data)
data |
A data frame. |
Logical scalar.
Requires rho, phi and theta; forbids z.
is_spherical(data)is_spherical(data)
data |
A data frame. |
Logical scalar.
Mutate columns in an aniframe
## S3 method for class 'aniframe' mutate(.data, ...)## S3 method for class 'aniframe' mutate(.data, ...)
.data |
An aniframe object |
... |
Name-value pairs of expressions |
An aniframe with modified columns
Rename columns with names<-
## S3 replacement method for class 'aniframe' names(x) <- value## S3 replacement method for class 'aniframe' names(x) <- value
x |
An aniframe object |
value |
New column names |
Modified aniframe
Convert radians to degrees
rad_to_deg(x)rad_to_deg(x)
x |
Numeric vector of angles (radians). |
Numeric vector of angles expressed in degrees.
Relocate columns in an aniframe
## S3 method for class 'aniframe' relocate(.data, ...)## S3 method for class 'aniframe' relocate(.data, ...)
.data |
An aniframe object |
... |
Columns to relocate |
An aniframe with relocated columns
Remove from/to pairs from the connections of a variable. Matching is
exact and order-sensitive: remove_connections(data, "a", "b") removes
the pair (from = "a", to = "b") but does not remove (from = "b", to = "a"). Call twice with swapped arguments if you want both directions
gone.
remove_connections(data, from, to, variable = "keypoint")remove_connections(data, from, to, variable = "keypoint")
data |
An aniframe object. |
from |
Character vector of source endpoints to remove. |
to |
Character vector of target endpoints to remove. Must be the same
length as |
variable |
Character scalar. Name of the variable. Defaults to
|
The aniframe with matching connections removed.
set_connections(), get_connections(), add_connections()
## Not run: data <- example_aniframe() |> add_connections(from = c("head", "neck"), to = c("neck", "shoulder_right")) data <- remove_connections(data, from = "head", to = "neck") ## End(Not run)## Not run: data <- example_aniframe() |> add_connections(from = c("head", "neck"), to = c("neck", "shoulder_right")) data <- remove_connections(data, from = "head", to = "neck") ## End(Not run)
Rename columns in an aniframe
## S3 method for class 'aniframe' rename(.data, ...)## S3 method for class 'aniframe' rename(.data, ...)
.data |
An aniframe object |
... |
Name-value pairs for renaming |
An aniframe with renamed columns
Select columns from an aniframe
## S3 method for class 'aniframe' select(.data, ...)## S3 method for class 'aniframe' select(.data, ...)
.data |
An aniframe object |
... |
Columns to select |
An aniframe with selected columns
Replace the connections (e.g. skeleton edges between keypoints, edges of a
social network between individuals) for a single variable. Connections are
stored as a 2-column from/to tibble; storage preserves the order
supplied so downstream consumers can interpret the table as either
directed or undirected.
set_connections(data, connections, variable = "keypoint")set_connections(data, connections, variable = "keypoint")
data |
An aniframe object. |
connections |
One of:
|
variable |
Character scalar. Name of the identity ( |
If any from/to value isn't found in the corresponding column of data,
a warning is emitted but the connection is kept — the value may legitimately
be missing in this particular recording while being valid elsewhere.
The aniframe with updated connections metadata.
get_connections(), add_connections(), remove_connections()
## Not run: data <- example_aniframe() # Implicit by position (element[1] = from, element[2] = to) data <- set_connections( data, list( c("head", "neck"), c("neck", "shoulder_right"), c("neck", "shoulder_left"), c("shoulder_right", "hip_right"), c("shoulder_left", "hip_left") ) ) # Explicit names within each pair data <- set_connections( data, list( c(from = "head", to = "neck"), c(from = "neck", to = "shoulder_right") ) ) # Or as a 2-column data.frame data <- set_connections( data, data.frame( from = c("head", "neck"), to = c("neck", "shoulder_right") ) ) ## End(Not run)## Not run: data <- example_aniframe() # Implicit by position (element[1] = from, element[2] = to) data <- set_connections( data, list( c("head", "neck"), c("neck", "shoulder_right"), c("neck", "shoulder_left"), c("shoulder_right", "hip_right"), c("shoulder_left", "hip_left") ) ) # Explicit names within each pair data <- set_connections( data, list( c(from = "head", to = "neck"), c(from = "neck", to = "shoulder_right") ) ) # Or as a 2-column data.frame data <- set_connections( data, data.frame( from = c("head", "neck"), to = c("neck", "shoulder_right") ) ) ## End(Not run)
Sets or updates metadata for an aniframe object. Metadata can be provided either as named arguments or as a list. If the aniframe already has metadata, the new values will be merged with existing values, with new values taking precedence.
Character values for factor fields will be automatically converted to factors if they match allowed levels.
Default metadata fields include:
source: Data source identifier
source_version: Version of the data source
filename: Original filename(s) — accepts a character vector
(length 1 or more) for readers that load from multiple files
sampling_rate: Sampling rate in Hz
start_datetime: Start date and time of recording
reference_frame: Reference frame (default: "allocentric")
coordinate_system: Coordinate system (default: "cartesian")
origin: Location of the (0,0) coordinate (default: "bottom_left")
y_height: Height of the recording frame in y-axis units (default: NA)
For backwards compatibility, the deprecated field point_of_reference is
accepted as an alias for origin and emits a deprecation warning.
set_metadata(data, ..., metadata = NULL)set_metadata(data, ..., metadata = NULL)
data |
An aniframe object |
... |
Named metadata values (e.g., |
metadata |
Alternatively, a named list of metadata. Cannot be used
simultaneously with |
The aniframe object with updated metadata
get_metadata(), default_metadata()
## Not run: # Set metadata using named arguments data <- set_metadata(data, sampling_rate = 30, source = "sleap") # Set metadata using a list md <- list(sampling_rate = 30, source = "sleap") data <- set_metadata(data, metadata = md) ## End(Not run)## Not run: # Set metadata using named arguments data <- set_metadata(data, sampling_rate = 30, source = "sleap") # Set metadata using a list md <- list(sampling_rate = 30, source = "sleap") data <- set_metadata(data, metadata = md) ## End(Not run)
Sets or updates the origin metadata field, which records where the (0,0)
coordinate sits relative to the recording frame. When the new origin
differs from the current one, the y coordinates are reflected around
y_height so the data is expressed in the new convention.
set_origin(data, origin)set_origin(data, origin)
data |
An aniframe object. |
origin |
Character. One of |
The flip uses the formula y_new = y_height - y_old. The y_height
metadata field must therefore be set when the origin actually changes; if
it is NA, this function errors and asks the user to set it via
set_y_height(). When the supplied origin matches the current value,
the data is returned unchanged.
The aniframe with reflected y coordinates (when the origin changed)
and updated origin metadata.
## Not run: data <- example_aniframe() data <- set_y_height(data, y_height = 1080) data <- set_origin(data, origin = "top_left") ## End(Not run)## Not run: data <- example_aniframe() data <- set_y_height(data, y_height = 1080) data <- set_origin(data, origin = "top_left") ## End(Not run)
Sets the sampling rate (in Hz) for an aniframe object and optionally converts time values from frames to seconds. If the data is already in SI time units, only the metadata is updated without modifying the time values.
set_sampling_rate(data, sampling_rate)set_sampling_rate(data, sampling_rate)
data |
An aniframe object containing time data. |
sampling_rate |
Numeric value specifying the sampling rate in Hz (samples per second). For example, a sampling rate of 30 means 30 frames per second. |
The function performs the following operations:
Checks the current unit_time in the object's metadata
If unit_time is "frame" or "unknown", converts time values to seconds using the formula: time_in_seconds = time_in_frames / sampling_rate
If unit_time is already an SI unit (ms, s, m, h), leaves time values unchanged and issues an informational message
Updates the sampling_rate in the object's metadata regardless of the current unit_time
This function is particularly useful when working with motion capture or video data where time is initially recorded as frame numbers.
An aniframe object with updated sampling_rate metadata and, if applicable, time values converted from frames to seconds.
## Not run: # Set sampling rate for data in frames (converts to seconds) data_with_rate <- set_sampling_rate(data, sampling_rate = 30) # Set sampling rate for data already in SI units (updates metadata only) data_with_rate <- set_sampling_rate(data, sampling_rate = 100) ## End(Not run)## Not run: # Set sampling rate for data in frames (converts to seconds) data_with_rate <- set_sampling_rate(data, sampling_rate = 30) # Set sampling rate for data already in SI units (updates metadata only) data_with_rate <- set_sampling_rate(data, sampling_rate = 100) ## End(Not run)
Converts angular columns in an aniframe between degrees ("deg") and
radians ("rad"), and updates the unit_angle metadata to match.
Spatial angular columns (phi, theta) are converted automatically
whenever they are present in the data, so polar/cylindrical/spherical
coordinates always stay consistent with the declared unit. Additional
angular columns (e.g. heading or orientation columns named outside the
polar family) can be supplied via cols.
set_unit_angle(data, to_unit, cols = NULL)set_unit_angle(data, to_unit, cols = NULL)
data |
An aniframe object containing angular data. |
to_unit |
Character string specifying the target angular unit. Must
be one of |
cols |
Optional character vector of additional angular column names
to convert. The spatial angular columns |
If the current unit_angle already matches to_unit, an informational
message is shown and the data are returned unchanged (apart from the
metadata round-trip).
An aniframe object with the relevant angular columns converted to
the specified unit and unit_angle metadata updated accordingly.
## Not run: # Polar data: phi is converted automatically df <- data.frame(time = 1:3, rho = 1:3, phi = c(0, pi / 2, pi)) anif <- as_aniframe(df) anif_deg <- set_unit_angle(anif, to_unit = "deg") # Custom angular columns alongside the spatial ones anif2 <- set_unit_angle(anif, to_unit = "deg", cols = "heading") ## End(Not run)## Not run: # Polar data: phi is converted automatically df <- data.frame(time = 1:3, rho = 1:3, phi = c(0, pi / 2, pi)) anif <- as_aniframe(df) anif_deg <- set_unit_angle(anif, to_unit = "deg") # Custom angular columns alongside the spatial ones anif2 <- set_unit_angle(anif, to_unit = "deg", cols = "heading") ## End(Not run)
Converts spatial coordinates (x, y, z) in an aniframe object to a different unit of measurement. The function handles both automatic unit conversion between standard units and custom calibration from pixel or arbitrary units.
set_unit_space(data, to_unit, calibration_factor = 1)set_unit_space(data, to_unit, calibration_factor = 1)
data |
An aniframe object containing spatial coordinate data. |
to_unit |
Character string specifying the target spatial unit. Must be
one of the permitted units defined in |
calibration_factor |
Numeric value for scaling spatial coordinates. Default is 1. When converting from standard units (mm, cm, m), this is ignored and the appropriate conversion factor is calculated automatically. When converting from "px" or "unknown", you must provide a calibration factor to define the relationship between the current units and the target unit. |
The function performs the following operations:
Validates that to_unit is a permitted spatial unit
Determines the current spatial unit from the object's metadata
If converting from standard units (mm, cm, m) to another standard unit, automatically calculates the conversion factor
If converting from "px" or "unknown" units with calibration_factor = 1,
issues an informational message and returns data unchanged
Applies the calibration factor to all spatial columns (x, y, z) that exist in the data
Updates the object's unit_space metadata
An aniframe object with spatial coordinates converted to the specified unit and updated metadata reflecting the new unit_space.
## Not run: # Convert from millimeters to centimeters (automatic conversion) data_cm <- set_unit_space(data, to_unit = "cm") # Convert from pixels to millimeters with custom calibration # (e.g., 1 pixel = 0.5 mm) data_mm <- set_unit_space(data, to_unit = "mm", calibration_factor = 0.5) ## End(Not run)## Not run: # Convert from millimeters to centimeters (automatic conversion) data_cm <- set_unit_space(data, to_unit = "cm") # Convert from pixels to millimeters with custom calibration # (e.g., 1 pixel = 0.5 mm) data_mm <- set_unit_space(data, to_unit = "mm", calibration_factor = 0.5) ## End(Not run)
Converts time values in an aniframe object to a different unit of measurement. The function handles both automatic unit conversion between standard time units and custom calibration from frame or arbitrary units.
set_unit_time(data, to_unit, calibration_factor = 1)set_unit_time(data, to_unit, calibration_factor = 1)
data |
An aniframe object containing time data. |
to_unit |
Character string specifying the target time unit. Must be
one of the permitted units defined in |
calibration_factor |
Numeric value for scaling time values. Default is 1. When converting from standard time units (ms, s, m, h), this is ignored and the appropriate conversion factor is calculated automatically. When converting from "frame" or "unknown" units, you must provide a calibration factor to define the relationship between the current units and the target unit. |
The function performs the following operations:
Validates that to_unit is a permitted time unit
Determines the current time unit from the object's metadata
If converting from standard time units (ms, s, m, h) to another standard unit, automatically calculates the conversion factor
If converting from "frame" or "unknown" units with calibration_factor = 1,
issues an informational message and returns data unchanged
Applies the calibration factor to the time column
Updates the object's unit_time metadata
An aniframe object with time values converted to the specified unit and updated metadata reflecting the new unit_time.
## Not run: # Convert from milliseconds to seconds (automatic conversion) data_s <- set_unit_time(data, to_unit = "s") # Convert from frames to seconds with custom calibration # (e.g., 30 frames per second means 1 frame = 1/30 seconds) data_s <- set_unit_time(data, to_unit = "s", calibration_factor = 1/30) # Convert from hours to minutes (automatic conversion) data_m <- set_unit_time(data, to_unit = "m") ## End(Not run)## Not run: # Convert from milliseconds to seconds (automatic conversion) data_s <- set_unit_time(data, to_unit = "s") # Convert from frames to seconds with custom calibration # (e.g., 30 frames per second means 1 frame = 1/30 seconds) data_s <- set_unit_time(data, to_unit = "s", calibration_factor = 1/30) # Convert from hours to minutes (automatic conversion) data_m <- set_unit_time(data, to_unit = "m") ## End(Not run)
Sets or updates the y_height metadata field, which records the height of
the recording frame in y-axis units. Used by set_origin() when reflecting
y coordinates between origin conventions (e.g. bottom_left <-> top_left).
Reader functions in aniread populate y_height automatically from the
source (e.g. video frame height). For aniframes constructed manually,
as_aniframe() falls back to max(y). Use this function to set the true
frame height when the auto-fallback is not appropriate.
set_y_height(data, y_height)set_y_height(data, y_height)
data |
An aniframe object. |
y_height |
A single positive finite numeric value. |
The aniframe with updated y_height metadata.
## Not run: data <- example_aniframe() data <- set_y_height(data, y_height = 1080) ## End(Not run)## Not run: data <- example_aniframe() data <- set_y_height(data, y_height = 1080) ## End(Not run)
Slice rows from an aniframe
## S3 method for class 'aniframe' slice(.data, ..., .preserve = FALSE)## S3 method for class 'aniframe' slice(.data, ..., .preserve = FALSE)
.data |
An aniframe object |
... |
Integer row positions |
.preserve |
Keep group structure |
A sliced aniframe
Builds the print header rows shown above an aniframe. The set of rows is
driven by the metadata: one row per column listed in variables_what and
one row per column in variables_when (excluding time). This means custom
identity/temporal variables (e.g. track, model, session) appear
automatically, and rows are omitted entirely when their column is absent.
## S3 method for class 'aniframe' tbl_sum(x, ...)## S3 method for class 'aniframe' tbl_sum(x, ...)
x |
An aniframe object |
... |
Additional arguments (unused) |
Named character vector with summary information
Ungroup an aniframe
## S3 method for class 'aniframe' ungroup(x, ...)## S3 method for class 'aniframe' ungroup(x, ...)
x |
An aniframe object |
... |
Additional arguments passed to dplyr::ungroup |
An ungrouped aniframe