create_points {rts2}R Documentation

Create sf object from point location data

Description

Produces an sf object with location and time of cases from a data frame

Usage

create_points(
  data,
  pos_vars = c("lat", "long"),
  t_var,
  format = "%Y-%m-%d",
  verbose = TRUE
)

Arguments

data

data.frame with the x- and y-coordinate of case locations and the date of the case.

pos_vars

vector of length two with the names of the columns containing the y and x coordinates, respectively.

t_var

character string with the name of the column with the date of the case. If single-period analysis then set t_var to NULL.

format

character string with the format of the date specified by t_var. See strptime

verbose

Logical indicating whether to print information

Details

Given a data frame containing the point location and date of cases, the function will return an sf object of the points with the date information.

Value

An sf object of the same size as data

Examples

dp <- data.frame(y=runif(10,0,3),x=runif(10,0,3),date=paste0("2021-01-",11:20))
dp <- create_points(dp,pos_vars = c('y','x'),t_var='date')

[Package rts2 version 0.7.5 Index]