Learn R Programming

mpathsenser (version 1.2.4)

add_timezones_to_db: Add timezone to measurements in an m-Path Sense database

Description

[Experimental]

This function looks for a Timezone table in a local m-Path Sense SQLite database and uses it to assign timezone values to all other sensor tables. For each observation in a sensor table, it finds the timezone interval that matches the observation's timestamp and adds or updates a timezone column accordingly.

Usage

add_timezones_to_db(db, sensors = NULL, .progress = TRUE)

Value

Invisibly returns TRUE if all updates complete successfully.

Arguments

db

A database connection, typically created by open_db().

sensors

A character vector of sensor table names to update. Defaults to NULL for all supported sensors.

.progress

Logical; whether to show a progress bar during processing. Defaults to TRUE.

Details

Note that rerunning this function overwrites existing timezone columns in the sensor tables. Also note that if a measurement matches multiple time zones (i.e. a timezone change occurred during the measurement), the timezone with the longest overlap is chosen.

Examples

Run this code
if (FALSE) {
# Connect to an m-Path Sense database
db <- open_db("path/to/db.sqlite")

# Add timezone information to all tables
add_timezones_to_db(db)

# Disconnect when done
close_db(db)
}

Run the code above in your browser using DataLab