Skip to contents

Create a GeoPressureR tag object from the data collected by a tracking device. This data needs to include at least pressure and optionally a light and/or acceleration.

The current implementation can read files from the following three manufacturer:

You can also enter the data manually (manufacturer = "manual") by providing the data.frame to pressure_file:

  • pressure_file: data.frame with column date and value.

  • light_file: (optional) data.frame with column date and value.

  • acceleration_file: (optional) data.frame with column date and value.

By default manufacturer = NULL, the manufacturer is determined automatically from the content of the directory. You can also specify manually the file with a full pathname or the file extension using a regex expression (e.g., "*.pressure" matches any file ending with pressure).

Please create an issue on Github if you have data in a format that is not yet supported.

This function can be used to crop the data at specific date, for instance to remove pre-equipment or post-retrieval data.

Usage

tag_create(
  id,
  manufacturer = NULL,
  crop_start = NULL,
  crop_end = NULL,
  directory = glue::glue("./data/raw-tag/{id}"),
  pressure_file = NULL,
  light_file = NULL,
  acceleration_file = NULL,
  temperature_file = NULL,
  quiet = FALSE
)

Arguments

id

unique identifier of a tag.

manufacturer

One of NULL, "soi", "migratetech", "lund" or "manual"

crop_start

remove all data before this date (POSIXct or character in UTC).

crop_end

remove all data after this date (POSIXct or character in UTC).

directory

path of the directory where the tag files can be read.

pressure_file

name of the file with pressure data. Full pathname or finishing with extensions (e.g., "*.pressure", "*.deg" or "*_press.xlsx").

light_file

name of the file with light data. Full pathname or finishing with extensions (e.g., "*.glf", "*.lux" or "*_acc.xlsx").

acceleration_file

name of the file with acceleration data. Full pathname or finishing with extensions (e.g., "*.acceleration", "*.deg" or "*_acc.xlsx").

temperature_file

name of the file with temperature data. Full pathname or finishing with extensions (e.g., "*.temperature", "*.deg").

quiet

logical to hide messages about the progress.

Value

a GeoPressureR tag object containing

  • param parameter object (see param_create)

  • pressure data.frame with columns for date and value

  • light (optional) same structure as pressure

  • acceleration (optional) same structure as pressure

See also

Examples

setwd(system.file("extdata", package = "GeoPressureR"))

# Read all sensor file
tag <- tag_create("18LX")
#>  Read ./data/raw-tag/18LX/18LX_20180725.pressure
#>  Read ./data/raw-tag/18LX/18LX_20180725.glf
#>  Read ./data/raw-tag/18LX/18LX_20180725.acceleration
#>  Read ./data/raw-tag/18LX/18LX_20180725.temperature

print(tag)
#> 
#> ── GeoPressureR `tag` object for 18LX ──────────────────────────────────────────
#> Note: All green texts are fields of `tag` (i.e., `tag$field`).
#> 
#> ── Parameter param 
#> Run `tag$param` to display full table
#> 
#> ── Sensors data 
#> Manufacturer: soi
#> Date range: 2017-07-27 to 2017-08-09 23:30:00
#>  pressure: 672 datapoints
#>  acceleration: 4032 datapoints
#>  light: 4032 datapoints
#>  temperature: 2448 datapoints
#> 
#> ── Stationary periods stap 
#>  No stationary periods defined yet. Use `tag_label()`

# Read only pressure and crop date
tag <- tag_create("18LX",
  light_file = NULL,
  acceleration_file = NULL,
  crop_start = "2017-08-01",
  crop_end = "2017-08-05"
)
#>  Read ./data/raw-tag/18LX/18LX_20180725.pressure
#>  Read ./data/raw-tag/18LX/18LX_20180725.glf
#>  Read ./data/raw-tag/18LX/18LX_20180725.acceleration
#>  Read ./data/raw-tag/18LX/18LX_20180725.temperature

print(tag)
#> 
#> ── GeoPressureR `tag` object for 18LX ──────────────────────────────────────────
#> Note: All green texts are fields of `tag` (i.e., `tag$field`).
#> 
#> ── Parameter param 
#> Run `tag$param` to display full table
#> 
#> ── Sensors data 
#> Manufacturer: soi
#> Date range: 2017-08-01 to 2017-08-04 23:30:00
#>  pressure: 192 datapoints
#>  acceleration: 1152 datapoints
#>  light: 1152 datapoints
#>  temperature: 2448 datapoints
#> 
#> ── Stationary periods stap 
#>  No stationary periods defined yet. Use `tag_label()`

# You can also specify the exact file in case multiple files with the
# same extension exist in your directory (migratetech data)
tag <- tag_create("CB621",
  pressure_file = "CB621_BAR.deg",
  light_file = "CB621.lux",
  acceleration_file = NULL
)
#>  Read ./data/raw-tag/CB621/CB621_BAR.deg
#>  Read ./data/raw-tag/CB621/CB621_BAR.deg
#>  Read ./data/raw-tag/CB621/CB621.lux

print(tag)
#> 
#> ── GeoPressureR `tag` object for CB621 ─────────────────────────────────────────
#> Note: All green texts are fields of `tag` (i.e., `tag$field`).
#> 
#> ── Parameter param 
#> Run `tag$param` to display full table
#> 
#> ── Sensors data 
#> Manufacturer: migratetech
#> Date range: 2021-06-15 21:38:35 to 2021-06-16 05:08:35
#>  pressure: 16 datapoints
#>  light: 14 datapoints
#>  temperature: 16 datapoints
#> 
#> ── Stationary periods stap 
#>  No stationary periods defined yet. Use `tag_label()`

# You can specify the data manually with
pressure <- data.frame(
  date = as.POSIXct(c(
    "2017-06-20 00:00:00 UTC", "2017-06-20 01:00:00 UTC",
    "2017-06-20 02:00:00 UTC", "2017-06-20 03:00:00 UTC"
  ), tz = "UTC"),
  value = c(1000, 1000, 1000, 1000)
)
tag_create(id = "xxx", pressure_file = pressure)
#> List of 2
#>  $ param   :List of 8
#>   ..$ id                  : chr "xxx"
#>   ..$ GeoPressureR_version:Classes 'package_version', 'numeric_version'  hidden list of 1
#>   .. ..$ : int [1:3] 3 2 1
#>   ..$ pressure_file       : chr "manual"
#>   ..$ light_file          : chr "manual"
#>   ..$ acceleration_file   : chr "manual"
#>   ..$ temperature_file    : chr "manual"
#>   ..$ manufacturer        : chr "manual"
#>   ..$ directory           : 'glue' chr "./data/raw-tag/xxx"
#>   ..- attr(*, "class")= chr "param"
#>  $ pressure:'data.frame':	4 obs. of  2 variables:
#>   ..$ date : POSIXct[1:4], format: "2017-06-20 00:00:00" "2017-06-20 01:00:00" ...
#>   ..$ value: num [1:4] 1000 1000 1000 1000
#>  - attr(*, "class")= chr "tag"