pTs: Create a pTs object

Description Usage Arguments Details Value Author(s) Source See Also Examples

View source: R/pTs.R

Description

This function takes a base R vector, matrix, or ts object and converts it to a "pTs" object.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
pTs(
  data,
  time = NULL,
  lat = NA,
  lon = NA,
  name = "",
  history = "",
  date = TRUE,
  kTol = 1/400
)

Arguments

data

a vector, matrix or ts object to be converted. If missing, a matrix, filled with NA values, with dimensions according to the lengths of time and name is created. For this, time needs to be non-NULL.

time

vector of time points corresponding to the observations in the proxy time series; must be equidistant. If NULL (the default), a vector of length length(data) (or nrow(data)) is created assuming equidistant time steps with stepsize 1. For this, data needs to be non-NULL.

lat

numeric vector giving the latitude(s) of the sampling location(s) of the proxy time series.

lon

vector of length 1 giving the longitude(s) of the sampling location(s) of the proxy time series.

name

vector of character strings with the names of the "pTs" object to be generated (optional).

history

character string to append to the history attribute of the "pTs" object (optional).

date

logical, whether or not to append the current date to the history attribute; defaults to TRUE.

kTol

tolerance to check for equidistance of time steps; defaults to 1/400.

Details

"pTs" ("proxy time series") objects are enhanced time-series ts objects. pTs() adds attributes such as longitude and latitude to a time series vector/time series vectors and assigns the class "pTs" to the resulting object. More than one time series vectors need to have the same time basis and can either stem from the same location (i.e. different data sets/proxies recorded at the same site, thus lat, lon are of length 1), or it can be the same proxy data recorded at different sites (i.e. lat, lon are vectors of the same length > 1). The latter can be used for irregular data fields which cannot be shaped into a pField object.

Value

An object of class "pTs".

Author(s)

Thomas Laepple; adapated by Thomas Münch

Source

Function copied from "proxytype.R" in paleolibary/src/.

See Also

pField

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# 10 data sets from the same site (e.g. Kohnen Station, Antarctica)

dat <- matrix(rnorm(10 * 100), nrow = 100, ncol = 10)
dat.pts <- pTs(dat, lat = -75, lon = 0,
               name = "10 proxy time series from Kohnen.")

# time vector is automatically created
time(dat.pts)

# supply a specific time vector
dat.pts <- pTs(dat, time = 1901 : 2000, lat = -75, lon = 0,
               name = "10 proxy time series from Kohnen.")
time(dat.pts)

# supply data set names
dat.pts <- pTs(dat, time = 1901 : 2000, lat = -75, lon = 0,
               name = paste("proxy", 1 : 10))

# 10 data sets from different sites
# (= irregular grid which cannot be shaped into a pField)

lat <- seq(-75, -85, length.out = 10)
lon <- seq(0, 90, length.out = 10)

dat.pts <- pTs(dat, time = 1901 : 2000, lat = lat, lon = lon,
               name = "Proxy time series from 10 sites.")

EarthSystemDiagnostics/pfields documentation built on Jan. 10, 2022, 10:37 p.m.