# Load data.table
library(data.table)
data.table::setDTthreads(1)
# Read example data
DT <- fread(system.file("extdata", "DT.csv", package = "spatsoc"))
# Cast the character column to POSIXct
DT[, datetime := as.POSIXct(datetime, tz = 'UTC')]
# EPSG code for example data
utm <- 32736
# Build lines for each individual
lines <- build_lines(DT, projection = utm, id = 'ID', coords = c('X', 'Y'),
sortBy = 'datetime')
# Build lines for each individual by year
DT[, yr := year(datetime)]
lines <- build_lines(DT, projection = utm, id = 'ID', coords = c('X', 'Y'),
sortBy = 'datetime', splitBy = 'yr')
Run the code above in your browser using DataLab