diff --git a/R/data.R b/R/data.R index 2e5c1e9..f449b71 100644 --- a/R/data.R +++ b/R/data.R @@ -1,31 +1,31 @@ -#' Sex choices -#' -#' Allowed values for the sex column in bird metadata -#' +#' Sex choices. +#' +#' Allowed values for the sex column in bird metadata. +#' #' @format character vector "sex_choices" -#' Species choices -#' -#' Allowed values for the species column in bird metadata -#' +#' Species choices. +#' +#' Allowed values for the species column in bird metadata. +#' #' @format character vector "species_choices" -#' Tracks validated -#' +#' Tracks validated. +#' #' An example data table containing validated bird tracking data (only 100 #' records). This is what you can expect after successfully loading and #' validating tracking data. -#' +#' #' @format data table "tracks_validated" -#' Birds validated -#' +#' Birds validated. +#' #' An example data table containing validated bird metadata (only 2 records). #' This is what you can expect after successfully loading and validating bird #' metadata. -#' +#' #' @format data table -"birds_validated" \ No newline at end of file +"birds_validated" diff --git a/R/enrich.R b/R/enrich.R index 98e2fc7..3ce922d 100644 --- a/R/enrich.R +++ b/R/enrich.R @@ -1,14 +1,18 @@ -#' Calculate sunrise and sunset -#' @description This function calculate the sunrise and sunset in UTC -#' for a given location and date. Function was slightly modified but inspired -#' from this post: http://www.r-bloggers.com/approximate-sunrise-and-sunset-times/ -#' -#' @param dates vector containing POSIX dates -#' @param Lat Latitudes in WGS84 -#' @param Long Longitudes in WGS84 -#' @return named list with elements "sunrise" and "sunset" +#' Calculate sunrise and sunset. +#' +#' This function calculate the sunrise and sunset in UTC for a given location +#' and date. Function was slightly modified but inspired from this post: +#' +#' +#' @param dates Vector containing POSIX dates. +#' @param Lat Latitudes in WGS84. +#' @param Long Longitudes in WGS84. +#' +#' @return Named list with elements `sunrise` and `sunset`. +#' #' @export #' @importFrom maptools sunriset +#' #' @examples #' { #' suncalc.custom(ymd("2015-01-01"), Lat=50.821, Long=4.366) @@ -26,14 +30,18 @@ suncalc.custom <- function(dates,Lat,Long){ "sunset" = with_tz(sunset$time, "UTC"))) } -#' Join tracks and metadata -#' @description Join tracking data with bird metadata. If tracking records -#' are found that cannot be matched with bird metadata, the function stops. +#' Join tracks and metadata. +#' +#' Join tracking data with bird metadata. If tracking records are found that +#' cannot be matched with bird metadata, the function stops. +#' +#' @param tracking_data Tracking data as data table. +#' @param bird_data Bird metadata as data table. +#' +#' @return Data table containing the joined input data tables. #' -#' @param tracking_data Tracking data as data table -#' @param bird_data Bird metadata as data table -#' @return data table containing the joined input data tables #' @export +#' #' @examples #' \dontrun{ #' join_tracks_and_metadata(tracks_validated, birds_validated) @@ -88,15 +96,18 @@ join_tracks_and_metadata <- function(tracking_data, bird_data) { return(joined) } -#' Delete test records -#' @description Remove data that was recorded by a device before it was -#' mounted on the bird +#' Delete test records. +#' +#' Remove data that was recorded by a device before it was mounted on the bird. #' #' @param data Tracking data as a data table. Data should already be joined -#' using the join_tracks_and_metadata function as both the date_time and the -#' tracking_start_date_time column are needed. -#' @return New data table without the test records +#' using the `join_tracks_and_metadata()` function as both the `date_time` and +#' the `tracking_start_date_time` column are needed. +#' +#' @return New data table without the test records. +#' #' @export +#' #' @examples #' \dontrun{ #' delete_test_records(joined_data) @@ -105,12 +116,16 @@ delete_test_records <- function(data) { return(data[date_time >= tracking_started_at]) } -#' Add year, month, hour columns -#' @description Add the year, month and hour of the GPS fix in separate columns +#' Add year, month, hour columns. +#' +#' Add the year, month and hour of the GPS fix in separate columns. #' #' @param dt Tracking data as a data.table. -#' @return Nothing, columns are added in place +#' +#' @return Nothing, columns are added in place. +#' #' @export +#' #' @examples #' \dontrun{ #' add_year_month_hour(tracks_data) @@ -121,15 +136,19 @@ add_year_month_hour <- function(data) { data[, calc_hour := hour(date_time)] } -#' Add time since previous fix -#' @description Calculates the time (in seconds) since the birds last fix. -#' Data is first ordered by individual and date_time. Next, for each individual -#' the time difference between a fix and its previous fix is calculated. -#' -#' @param datatable A data.table with tracking data. Should at least include -#' a column `device_info_serial` and `date_time` -#' @return a new datatable with the time difference column (`calc_time_diff`) added to it. +#' Add time since previous fix. +#' +#' Calculates the time (in seconds) since the birds last fix. Data is first +#' ordered by `individual` and `date_time`. Next, for each individual the time +#' difference between a fix and its previous fix is calculated. +#' +#' @param datatable A data.table with tracking data. Should at least include a +#' column `device_info_serial` and `date_time`. +#' @return a new datatable with the time difference column (`calc_time_diff`) +#' added to it. +#' #' @export +#' #' @examples #' \dontrun{ #' add_time_since_previous_fix(tracking_data) @@ -142,12 +161,16 @@ add_time_since_previous_fix <- function(datatable) { } -#' Add Distance travelled -#' @description will calculate the distance travelled since previous GPS fix +#' Add distance travelled. +#' +#' Will calculate the distance travelled since previous GPS fix. +#' +#' @param dt Tracking data as data.table. +#' +#' @return Nothing. Distance (in meters) is added in place (`calc_distance_diff`). #' -#' @param dt tracking data as data.table -#' @return nothing. Distance (in meters) is added in place (`calc_distance_diff`) #' @export +#' #' @examples #' \dontrun{ #' add_dist_travelled(tracking_data) @@ -166,14 +189,18 @@ add_dist_travelled <- function(dt) { dt[, tmp.select := NULL] } -#' Add speed -#' @description calculates the average 2 dimensional speed of the individual since the -#' previous GPS fix +#' Add speed. +#' +#' Calculates the average 2 dimensional speed of the individual since the +#' previous GPS fix. +#' +#' @param dt Tracking data as data.table. Should contain column +#' `calc_distance_diff` and `calc_time_diff`. +#' +#' @return Nothing. Data is added in place as column `calc_speed_2d`. #' -#' @param dt tracking data as data.table. Should contain column `calc_distance_diff` -#' and column `calc_time_diff` -#' @return nothing. Data is added in place as column `calc_speed_2d` #' @export +#' #' @examples #' \dontrun{ #' add_speed(tracking_data) @@ -182,13 +209,18 @@ add_speed <- function(dt) { dt[, calc_speed_2d := (calc_distance_diff)/(as.numeric(calc_time_diff))] } -#' Add distance to colony -#' @description calculates the distance from the GPS position to the colony +#' Add distance to colony. +#' +#' Calculates the distance from the GPS position to the colony. +#' +#' @param dt Tracking data as data.table. Should contain columns `latitude`, +#' `longitude`, `colony_latitude`, `colony_longitude`. +#' +#' @return Nothing. Adds distance (in meters) in place as column +#' `calc_distance_to_colony`. #' -#' @param dt tracking data as data.table. Should contain columns `latitude`, -#' `longitude`, `colony_latitude`, `colony_longitude` -#' @return nothing. Adds distance (in meters) in place as columns `calc_distance_to_colony` #' @export +#' #' @examples #' \dontrun{ #' add_dist_to_colony(tracking_data) @@ -201,17 +233,22 @@ add_dist_to_colony <- function(dt) { )] } -#' Presence of sunlight -#' @description calculate the presence of sunlight for every GPS fix. This is done -#' using the `suncalc` function of the package `RAtmosphere`. If the date_time of -#' the GPS fix is after sunrise and before sunset, presence of sunlight is 1. Otherwise -#' it is set to 0. -#' -#' @param dt tracking data as data.table. Should contain columns `latitude`, `longitude` -#' and `date_time`. -#' @return nothing. Column `calc_sunlight` is added in place. This is a logical vector, indicating -#' wether sunlight was present at time and location of the GPS fix. +#' Presence of sunlight. +#' +#' Calculate the presence of sunlight for every GPS fix. This is done using the +#' `suncalc()` function of the package `RAtmosphere`. If the `date_time` of the +#' GPS fix is after sunrise and before sunset, presence of sunlight is `1`. +#' Otherwise it is set to `0`. +#' +#' @param dt Tracking data as data.table. Should contain columns `latitude`, +#' `longitude` and `date_time`. +#' +#' @return Nothing. Column `calc_sunlight` is added in place. This is a logical +#' vector, indicating whether sunlight was present at time and location of the +#' GPS fix. +#' #' @export +#' #' @examples #' \dontrun{ #' add_sunlight(tracking_data) @@ -222,20 +259,22 @@ add_sunlight <- function(dt) { #print(dt) } - -#' Flag outliers -#' @description Flag records that are suspect to be erronous. -#' The following checks are made: -#' - date_time < current date -#' - altitude < 1000 km -#' - speed < 33.3333 meters per second (= 120 km per hour) -#' - height_accuracy < 1000 +#' Flag outliers. +#' +#' Flag records that are suspect to be erronous. The following checks are made: +#' - `date_time` < current date +#' - `altitude` < 1000 km +#' - `speed` < 33.3333 meters per second (= 120 km per hour) +#' - `height_accuracy` < 1000 #' If one of these fails, the record gets flagged. #' -#' @param dt tracking data as data.table. -#' @return nothing. Flagging happens in place. New columns is called `calc_outlier` -#' and contains logical values. +#' @param dt Tracking data as data.table. +#' +#' @return Nothing. Flagging happens in place. New columns is called +#' `calc_outlier` and contains logical values. +#' #' @export +#' #' @examples #' \dontrun{ #' flag_outliers(tracking_data) @@ -250,14 +289,18 @@ flag_outliers <- function(dt) { ] } -#' Raster join -#' @description Join tracks with raster data -#' -#' @param dt Data table with tracking data. Geospatial points are created based on the -#' latitude and longitude field and WGS84 datum is expected. -#' @param raster_data A raster data object. See the package "raster". -#' @return nothing. The value of the raster for every point is added to the data -#' table in place +#' Raster join. +#' +#' Join tracks with raster data. +#' +#' @param dt Data table with tracking data. Geospatial points are created based +#' on the `latitude` and `longitude` field and WGS84 datum is expected. +#' +#' @param raster_data A raster data object. See the package `raster`. +#' +#' @return Nothing. The value of the raster for every point is added to the data +#' table in place. +#' #' @export raster_join <- function(dt, raster_data) { pts <- SpatialPoints(data.frame(x = dt$longitude, y = dt$latitude), @@ -267,16 +310,22 @@ raster_join <- function(dt, raster_data) { dt[, calc_raster_value := results] } -#' Join raster value with legend -#' @description Join the raster value with its legend -#' -#' @param dt Data table with tracking data. Expected to contain a column `calc_raster_value` -#' which is the result of joining this table with a raster layer. -#' @param legend a data table with the legend of the raster layer. It should contain a column -#' `id` and a column `value`. The `id` column should contain the values that are used in the -#' raster layer, while the `value` column contains the labels for these values. -#' @return New data table with an additional column "calc_raster_legend" +#' Join raster value with legend. +#' +#' Join the raster value with its legend. +#' +#' @param dt Data table with tracking data. Expected to contain a column +#' `calc_raster_value` which is the result of joining this table with a raster +#' layer. +#' @param legend Data table with the legend of the raster layer. It should +#' contain a column `id` and a column `value`. The `id` column should contain +#' the values that are used in the raster layer, while the `value` column +#' contains the labels for these values. +#' +#' @return New data table with an additional column `calc_raster_legend`. +#' #' @export +#' #' @examples #' \dontrun { #' join_raster_value_with_legend(datatable, legendcsv) @@ -289,19 +338,23 @@ join_raster_value_with_legend <- function(dt, legend) { return(newdt) } -#' Enrich data -#' @description Enrich the bird tracking data by precalculating attributes -#' and joining data with other sources. See the package vignette for a complete -#' description of the procedure. -#' -#' @param tracking_data Data table obtained by using the validate_tracks_data -#' function -#' @param bird_data Bird metadata obtained by using the validate_bird_data -#' function +#' Enrich data. +#' +#' Enrich the bird tracking data by precalculating attributes and joining data +#' with other sources. See the package vignette for a complete description of +#' the procedure. +#' +#' @param tracking_data Data table obtained by using the +#' `validate_tracks_data()` function. +#' @param bird_data Bird metadata obtained by using the `validate_bird_data()` +#' function. #' @param corine_raster_data Filename containing corine raster data to be joined #' with bird tracking data. -#' @return Data table containing enriched data +#' +#' @return Data table containing enriched data. +#' #' @export +#' #' @examples #' \dontrun { #' enrich_data(tracking_data, bird_data) @@ -323,4 +376,4 @@ enrich_data <- function(tracking_data, bird_data, corine_raster_data, corine_leg setnames(dt, "calc_raster_value", "calc_corine_value") setnames(dt, "calc_raster_legend", "calc_corine_legend") return(dt) -} \ No newline at end of file +} diff --git a/R/extract.R b/R/extract.R index 8e11286..023f851 100644 --- a/R/extract.R +++ b/R/extract.R @@ -1,11 +1,15 @@ -#' Check numeric values -#' @description Check whether values in given column can be converted to -#' numeric types. If not, this function will call stop(). +#' Check numeric values. +#' +#' Check whether values in given column can be converted to numeric types. If +#' not, this function will call `stop()`. +#' +#' @param colname Name of the column to be tested. +#' @param col Column containing values to be tested. +#' +#' @return `col` if all values can be converted to numeric. Otherwise error. #' -#' @param colname Name of the column to be tested -#' @param col Column containing values to be tested -#' @return col if all values can be converted to numeric. Otherwise error. #' @export +#' #' @examples #' check_numeric_values("testcol", c(1, 2, 3)) check_numeric_values <- function(colname, col) { @@ -16,15 +20,18 @@ check_numeric_values <- function(colname, col) { return(col) } - -#' Load file containing bird tracking data -#' @description Load a file containing bird tracking data. This file can -#' be obtained by requesting a dump from the UvA-BiTS virtual lab. +#' Load file containing bird tracking data. +#' +#' Load a file containing bird tracking data. This file can be obtained by +#' requesting a dump from the UvA-BiTS virtual lab. #' #' @param filename The file containing bird tracking data in csv -#' format. (','-delimited, header included) -#' @return A data table (not a data frame!) containing the tracking data +#' format. (','-delimited, header included). +#' +#' @return A data table (not a data frame!) containing the tracking data. +#' #' @export +#' #' @examples #' \dontrun{ #' load_tracks_file(inputFile) @@ -34,14 +41,17 @@ load_tracks_file <- function(filename) { data <- fread(filename, dec=".", header=TRUE, sep=",", na.strings=c("\\N")) } - -#' Validate tracking data -#' @description Validate the data coming either from a csv file or -#' from the UvA-BiTS virtual lab directly. +#' Validate tracking data. +#' +#' Validate the data coming either from a csv file or from the UvA-BiTS virtual +#' lab directly. +#' +#' @param tracks_data The tracking data as a data table. +#' +#' @return Validated tracking data as a data table if no errors are found. #' -#' @param tracks_data The tracking data as a data table -#' @return validated tracking data as a data table if no errors are found. #' @export +#' #' @examples #' \dontrun{ #' validate_tracks_data(tracking_data) @@ -104,14 +114,17 @@ validate_tracks_data <- function(tracks_data) { return(tracks_data) } -#' Load bird metadata file -#' @description Load a file containing bird metadata. This file is managed at the -#' INBO on Google Drive. Create a csv export of that file, and make sure it is -#' "," delimited. +#' Load bird metadata file. +#' +#' Load a file containing bird metadata. This file is managed at the INBO on +#' Google Drive. Create a csv export of that file, and make sure it is `,` +#' delimited. +#' +#' @param filename The name of the file containing bird metadata. +#' @return A data table (not a data frame!) containing the bird metadata. #' -#' @param filename The name of the file containing bird metadata -#' @return A data table (not a data frame!) containing the bird metadata #' @export +#' #' @examples #' \dontrun{ #' load_bird_file(inputFile) @@ -122,11 +135,14 @@ load_bird_file <- function(filename) { } -#' Validate bird data -#' @description Validate the bird metadata +#' Validate bird data. +#' +#' Validate the bird metadata. +#' +#' @param bird_data The bird metadata as a data table. +#' +#' @return Validated bird metadata as a data table if no errors are found. #' -#' @param bird_data The bird metadata as a data table -#' @return validated bird metadata as a data table if no errors are found. #' @export validate_bird_data <- function(bird_data) { issues <- c() @@ -196,15 +212,19 @@ validate_bird_data <- function(bird_data) { } -#' Read raster data -#' @description Read raster data using the raster package. By default -#' this function will set the CRS of this data to EPSG4326 (WGS 84). -#' Use the data.CRS parameter to override this. +#' Read raster data. +#' +#' Read raster data using the raster package. By default this function will set +#' the CRS of this data to EPSG4326 (WGS 84). Use the data.CRS parameter to +#' override this. +#' +#' @param filename Name of the file containing raster data. +#' @param data.CRS Coordinate Reference System of the data. +#' +#' @return Raster data as RasterLayer class. #' -#' @param filename Name of the file containing raster data -#' @param data.CRS Coordinate Reference System of the data -#' @return raster data as RasterLayer class #' @export +#' #' @examples #' \dontrun{ #' read_raster_data("raster_file.tiff", data.CRS="+init=epsg:2056") @@ -216,14 +236,18 @@ read_raster_data <- function(filename, data.CRS="+init=epsg:4326") { return(r) } -#' Read the raster legend -#' @description Read the raster legend. The legend is expected to contain two columns: -#' `id` containing the actual values used in the raster layer, and `value` which contains -#' the labels. +#' Read the raster legend. +#' +#' @description Read the raster legend. The legend is expected to contain two +#' columns: `id` containing the actual values used in the raster layer, and +#' `value` which contains the labels. +#' +#' @param filename Name of the csv file containing the raster legend. +#' +#' @return A data table containing the raster legend. #' -#' @param filename Name of the csv file containing the raster legend -#' @return a data table containing the raster legend #' @export +#' #' @examples #' \dontrun{ #' read_raster_legend("raster_legend.csv") @@ -231,4 +255,4 @@ read_raster_data <- function(filename, data.CRS="+init=epsg:4326") { read_raster_legend <- function(filename) { r <- fread(filename, dec=".", header=TRUE, sep=",", na.strings=c("")) return(r) -} \ No newline at end of file +} diff --git a/R/load.R b/R/load.R index e58b98e..63f2c53 100644 --- a/R/load.R +++ b/R/load.R @@ -1,10 +1,13 @@ -#' data2table -#' @description Load all the enriched data to a RDBMS table -#' -#' @param dbConnection a DBI database connection -#' @param data A data table containing all data. See the vignette to see the required -#' columns and how they are written to the database. -#' @return Nothing +#' Data to table. +#' +#' Load all the enriched data to a RDBMS table. +#' +#' @param dbConnection A DBI database connection. +#' @param data A data table containing all data. See the vignette to see the +#' required columns and how they are written to the database. +#' +#' @return Nothing. +#' #' @examples #' \dontrun{data2table(dbConnection, datatable)} #' @export diff --git a/R/profiling.R b/R/profiling.R index 1c30f92..97a3fad 100644 --- a/R/profiling.R +++ b/R/profiling.R @@ -1,13 +1,16 @@ -#' Profile UvA-BiTS ETL processing steps (Level 1) -#' @description Profile the different processing steps in the bird-trakcing-etl -#' package to find bottlenecks. +#' Profile UvA-BiTS ETL processing steps (Level 1). +#' +#' Profile the different processing steps in the bird-trakcing-etl package to +#' find bottlenecks. #' #' @param tracks_file CSV file containing tracking data used for profiling. #' Don't use a file that is too big (because it will take some time), but don't #' make it too small either (because that can introduces biases that are not -#' representative) +#' representative). #' @param birds_file CSV file containing bird tracking metadata. -#' @return Data.Frame with two columns: "step" and "timing" +#' +#' @return Data.Frame with two columns: `step` and `timing`. +#' #' @export #' @importFrom data.table melt profiling_L1 <- function(tracks_file, birds_file) { @@ -38,4 +41,4 @@ profiling_L1 <- function(tracks_file, birds_file) { d <- melt(plt_data,variable.name="step", value.name="timing") return(d) -} \ No newline at end of file +} diff --git a/man/add_dist_to_colony.Rd b/man/add_dist_to_colony.Rd index 4ff6136..bdd7efb 100644 --- a/man/add_dist_to_colony.Rd +++ b/man/add_dist_to_colony.Rd @@ -2,19 +2,20 @@ % Please edit documentation in R/enrich.R \name{add_dist_to_colony} \alias{add_dist_to_colony} -\title{Add distance to colony} +\title{Add distance to colony.} \usage{ add_dist_to_colony(dt) } \arguments{ -\item{dt}{tracking data as data.table. Should contain columns `latitude`, -`longitude`, `colony_latitude`, `colony_longitude`} +\item{dt}{Tracking data as data.table. Should contain columns \code{latitude}, +\code{longitude}, \code{colony_latitude}, \code{colony_longitude}.} } \value{ -nothing. Adds distance (in meters) in place as columns `calc_distance_to_colony` +Nothing. Adds distance (in meters) in place as column +\code{calc_distance_to_colony}. } \description{ -calculates the distance from the GPS position to the colony +Calculates the distance from the GPS position to the colony. } \examples{ \dontrun{ diff --git a/man/add_dist_travelled.Rd b/man/add_dist_travelled.Rd index a3a00c4..a572487 100644 --- a/man/add_dist_travelled.Rd +++ b/man/add_dist_travelled.Rd @@ -2,18 +2,18 @@ % Please edit documentation in R/enrich.R \name{add_dist_travelled} \alias{add_dist_travelled} -\title{Add Distance travelled} +\title{Add distance travelled.} \usage{ add_dist_travelled(dt) } \arguments{ -\item{dt}{tracking data as data.table} +\item{dt}{Tracking data as data.table.} } \value{ -nothing. Distance (in meters) is added in place (`calc_distance_diff`) +Nothing. Distance (in meters) is added in place (\code{calc_distance_diff}). } \description{ -will calculate the distance travelled since previous GPS fix +Will calculate the distance travelled since previous GPS fix. } \examples{ \dontrun{ diff --git a/man/add_speed.Rd b/man/add_speed.Rd index 595102b..0104428 100644 --- a/man/add_speed.Rd +++ b/man/add_speed.Rd @@ -2,20 +2,20 @@ % Please edit documentation in R/enrich.R \name{add_speed} \alias{add_speed} -\title{Add speed} +\title{Add speed.} \usage{ add_speed(dt) } \arguments{ -\item{dt}{tracking data as data.table. Should contain column `calc_distance_diff` -and column `calc_time_diff`} +\item{dt}{Tracking data as data.table. Should contain column +\code{calc_distance_diff} and \code{calc_time_diff}.} } \value{ -nothing. Data is added in place as column `calc_speed_2d` +Nothing. Data is added in place as column \code{calc_speed_2d}. } \description{ -calculates the average 2 dimensional speed of the individual since the -previous GPS fix +Calculates the average 2 dimensional speed of the individual since the +previous GPS fix. } \examples{ \dontrun{ diff --git a/man/add_sunlight.Rd b/man/add_sunlight.Rd index e8fa2c9..ec19181 100644 --- a/man/add_sunlight.Rd +++ b/man/add_sunlight.Rd @@ -2,23 +2,24 @@ % Please edit documentation in R/enrich.R \name{add_sunlight} \alias{add_sunlight} -\title{Presence of sunlight} +\title{Presence of sunlight.} \usage{ add_sunlight(dt) } \arguments{ -\item{dt}{tracking data as data.table. Should contain columns `latitude`, `longitude` -and `date_time`.} +\item{dt}{Tracking data as data.table. Should contain columns \code{latitude}, +\code{longitude} and \code{date_time}.} } \value{ -nothing. Column `calc_sunlight` is added in place. This is a logical vector, indicating -wether sunlight was present at time and location of the GPS fix. +Nothing. Column \code{calc_sunlight} is added in place. This is a logical +vector, indicating whether sunlight was present at time and location of the +GPS fix. } \description{ -calculate the presence of sunlight for every GPS fix. This is done -using the `suncalc` function of the package `RAtmosphere`. If the date_time of -the GPS fix is after sunrise and before sunset, presence of sunlight is 1. Otherwise -it is set to 0. +Calculate the presence of sunlight for every GPS fix. This is done using the +\code{suncalc()} function of the package \code{RAtmosphere}. If the \code{date_time} of the +GPS fix is after sunrise and before sunset, presence of sunlight is \code{1}. +Otherwise it is set to \code{0}. } \examples{ \dontrun{ diff --git a/man/add_time_since_previous_fix.Rd b/man/add_time_since_previous_fix.Rd index 0db6703..0f3fd06 100644 --- a/man/add_time_since_previous_fix.Rd +++ b/man/add_time_since_previous_fix.Rd @@ -2,21 +2,22 @@ % Please edit documentation in R/enrich.R \name{add_time_since_previous_fix} \alias{add_time_since_previous_fix} -\title{Add time since previous fix} +\title{Add time since previous fix.} \usage{ add_time_since_previous_fix(datatable) } \arguments{ -\item{datatable}{A data.table with tracking data. Should at least include -a column `device_info_serial` and `date_time`} +\item{datatable}{A data.table with tracking data. Should at least include a +column \code{device_info_serial} and \code{date_time}.} } \value{ -a new datatable with the time difference column (`calc_time_diff`) added to it. +a new datatable with the time difference column (\code{calc_time_diff}) +added to it. } \description{ -Calculates the time (in seconds) since the birds last fix. -Data is first ordered by individual and date_time. Next, for each individual -the time difference between a fix and its previous fix is calculated. +Calculates the time (in seconds) since the birds last fix. Data is first +ordered by \code{individual} and \code{date_time}. Next, for each individual the time +difference between a fix and its previous fix is calculated. } \examples{ \dontrun{ diff --git a/man/add_year_month_hour.Rd b/man/add_year_month_hour.Rd index b14c953..dd7f7b2 100644 --- a/man/add_year_month_hour.Rd +++ b/man/add_year_month_hour.Rd @@ -2,7 +2,7 @@ % Please edit documentation in R/enrich.R \name{add_year_month_hour} \alias{add_year_month_hour} -\title{Add year, month, hour columns} +\title{Add year, month, hour columns.} \usage{ add_year_month_hour(data) } @@ -10,10 +10,10 @@ add_year_month_hour(data) \item{dt}{Tracking data as a data.table.} } \value{ -Nothing, columns are added in place +Nothing, columns are added in place. } \description{ -Add the year, month and hour of the GPS fix in separate columns +Add the year, month and hour of the GPS fix in separate columns. } \examples{ \dontrun{ diff --git a/man/birds_validated.Rd b/man/birds_validated.Rd index 292bd42..9786a0e 100644 --- a/man/birds_validated.Rd +++ b/man/birds_validated.Rd @@ -3,7 +3,7 @@ \docType{data} \name{birds_validated} \alias{birds_validated} -\title{Birds validated} +\title{Birds validated.} \format{data table} \usage{ birds_validated diff --git a/man/check_numeric_values.Rd b/man/check_numeric_values.Rd index d26c5c5..51df702 100644 --- a/man/check_numeric_values.Rd +++ b/man/check_numeric_values.Rd @@ -2,21 +2,21 @@ % Please edit documentation in R/extract.R \name{check_numeric_values} \alias{check_numeric_values} -\title{Check numeric values} +\title{Check numeric values.} \usage{ check_numeric_values(colname, col) } \arguments{ -\item{colname}{Name of the column to be tested} +\item{colname}{Name of the column to be tested.} -\item{col}{Column containing values to be tested} +\item{col}{Column containing values to be tested.} } \value{ -col if all values can be converted to numeric. Otherwise error. +\code{col} if all values can be converted to numeric. Otherwise error. } \description{ -Check whether values in given column can be converted to -numeric types. If not, this function will call stop(). +Check whether values in given column can be converted to numeric types. If +not, this function will call \code{stop()}. } \examples{ check_numeric_values("testcol", c(1, 2, 3)) diff --git a/man/data2table.Rd b/man/data2table.Rd index 6390468..a59ba2b 100644 --- a/man/data2table.Rd +++ b/man/data2table.Rd @@ -2,21 +2,21 @@ % Please edit documentation in R/load.R \name{data2table} \alias{data2table} -\title{data2table} +\title{Data to table.} \usage{ data2table(dbConnection, data) } \arguments{ -\item{dbConnection}{a DBI database connection} +\item{dbConnection}{A DBI database connection.} -\item{data}{A data table containing all data. See the vignette to see the required -columns and how they are written to the database.} +\item{data}{A data table containing all data. See the vignette to see the +required columns and how they are written to the database.} } \value{ -Nothing +Nothing. } \description{ -Load all the enriched data to a RDBMS table +Load all the enriched data to a RDBMS table. } \examples{ \dontrun{data2table(dbConnection, datatable)} diff --git a/man/delete_test_records.Rd b/man/delete_test_records.Rd index a198e11..8f7a375 100644 --- a/man/delete_test_records.Rd +++ b/man/delete_test_records.Rd @@ -2,21 +2,20 @@ % Please edit documentation in R/enrich.R \name{delete_test_records} \alias{delete_test_records} -\title{Delete test records} +\title{Delete test records.} \usage{ delete_test_records(data) } \arguments{ \item{data}{Tracking data as a data table. Data should already be joined -using the join_tracks_and_metadata function as both the date_time and the -tracking_start_date_time column are needed.} +using the \code{join_tracks_and_metadata()} function as both the \code{date_time} and +the \code{tracking_start_date_time} column are needed.} } \value{ -New data table without the test records +New data table without the test records. } \description{ -Remove data that was recorded by a device before it was -mounted on the bird +Remove data that was recorded by a device before it was mounted on the bird. } \examples{ \dontrun{ diff --git a/man/enrich_data.Rd b/man/enrich_data.Rd index 4efe99e..f6df66d 100644 --- a/man/enrich_data.Rd +++ b/man/enrich_data.Rd @@ -2,27 +2,27 @@ % Please edit documentation in R/enrich.R \name{enrich_data} \alias{enrich_data} -\title{Enrich data} +\title{Enrich data.} \usage{ enrich_data(tracking_data, bird_data, corine_raster_data, corine_legend) } \arguments{ -\item{tracking_data}{Data table obtained by using the validate_tracks_data -function} +\item{tracking_data}{Data table obtained by using the +\code{validate_tracks_data()} function.} -\item{bird_data}{Bird metadata obtained by using the validate_bird_data -function} +\item{bird_data}{Bird metadata obtained by using the \code{validate_bird_data()} +function.} \item{corine_raster_data}{Filename containing corine raster data to be joined with bird tracking data.} } \value{ -Data table containing enriched data +Data table containing enriched data. } \description{ -Enrich the bird tracking data by precalculating attributes -and joining data with other sources. See the package vignette for a complete -description of the procedure. +Enrich the bird tracking data by precalculating attributes and joining data +with other sources. See the package vignette for a complete description of +the procedure. } \examples{ \dontrun { diff --git a/man/flag_outliers.Rd b/man/flag_outliers.Rd index fa3f0fe..623c56b 100644 --- a/man/flag_outliers.Rd +++ b/man/flag_outliers.Rd @@ -2,26 +2,27 @@ % Please edit documentation in R/enrich.R \name{flag_outliers} \alias{flag_outliers} -\title{Flag outliers} +\title{Flag outliers.} \usage{ flag_outliers(dt) } \arguments{ -\item{dt}{tracking data as data.table.} +\item{dt}{Tracking data as data.table.} } \value{ -nothing. Flagging happens in place. New columns is called `calc_outlier` -and contains logical values. +Nothing. Flagging happens in place. New columns is called +\code{calc_outlier} and contains logical values. } \description{ -Flag records that are suspect to be erronous. -The following checks are made: - - date_time < current date - - altitude < 1000 km - - speed < 33.3333 meters per second (= 120 km per hour) - - height_accuracy < 1000 +Flag records that are suspect to be erronous. The following checks are made: +\itemize{ +\item \code{date_time} < current date +\item \code{altitude} < 1000 km +\item \code{speed} < 33.3333 meters per second (= 120 km per hour) +\item \code{height_accuracy} < 1000 If one of these fails, the record gets flagged. } +} \examples{ \dontrun{ flag_outliers(tracking_data) diff --git a/man/join_raster_value_with_legend.Rd b/man/join_raster_value_with_legend.Rd index b28e404..00241b4 100644 --- a/man/join_raster_value_with_legend.Rd +++ b/man/join_raster_value_with_legend.Rd @@ -2,23 +2,25 @@ % Please edit documentation in R/enrich.R \name{join_raster_value_with_legend} \alias{join_raster_value_with_legend} -\title{Join raster value with legend} +\title{Join raster value with legend.} \usage{ join_raster_value_with_legend(dt, legend) } \arguments{ -\item{dt}{Data table with tracking data. Expected to contain a column `calc_raster_value` -which is the result of joining this table with a raster layer.} +\item{dt}{Data table with tracking data. Expected to contain a column +\code{calc_raster_value} which is the result of joining this table with a raster +layer.} -\item{legend}{a data table with the legend of the raster layer. It should contain a column -`id` and a column `value`. The `id` column should contain the values that are used in the -raster layer, while the `value` column contains the labels for these values.} +\item{legend}{Data table with the legend of the raster layer. It should +contain a column \code{id} and a column \code{value}. The \code{id} column should contain +the values that are used in the raster layer, while the \code{value} column +contains the labels for these values.} } \value{ -New data table with an additional column "calc_raster_legend" +New data table with an additional column \code{calc_raster_legend}. } \description{ -Join the raster value with its legend +Join the raster value with its legend. } \examples{ \dontrun { diff --git a/man/join_tracks_and_metadata.Rd b/man/join_tracks_and_metadata.Rd index 97ff24d..5bb866f 100644 --- a/man/join_tracks_and_metadata.Rd +++ b/man/join_tracks_and_metadata.Rd @@ -2,21 +2,21 @@ % Please edit documentation in R/enrich.R \name{join_tracks_and_metadata} \alias{join_tracks_and_metadata} -\title{Join tracks and metadata} +\title{Join tracks and metadata.} \usage{ join_tracks_and_metadata(tracking_data, bird_data) } \arguments{ -\item{tracking_data}{Tracking data as data table} +\item{tracking_data}{Tracking data as data table.} -\item{bird_data}{Bird metadata as data table} +\item{bird_data}{Bird metadata as data table.} } \value{ -data table containing the joined input data tables +Data table containing the joined input data tables. } \description{ -Join tracking data with bird metadata. If tracking records -are found that cannot be matched with bird metadata, the function stops. +Join tracking data with bird metadata. If tracking records are found that +cannot be matched with bird metadata, the function stops. } \examples{ \dontrun{ diff --git a/man/load_bird_file.Rd b/man/load_bird_file.Rd index 0d1c649..2b6970f 100644 --- a/man/load_bird_file.Rd +++ b/man/load_bird_file.Rd @@ -2,20 +2,20 @@ % Please edit documentation in R/extract.R \name{load_bird_file} \alias{load_bird_file} -\title{Load bird metadata file} +\title{Load bird metadata file.} \usage{ load_bird_file(filename) } \arguments{ -\item{filename}{The name of the file containing bird metadata} +\item{filename}{The name of the file containing bird metadata.} } \value{ -A data table (not a data frame!) containing the bird metadata +A data table (not a data frame!) containing the bird metadata. } \description{ -Load a file containing bird metadata. This file is managed at the -INBO on Google Drive. Create a csv export of that file, and make sure it is -"," delimited. +Load a file containing bird metadata. This file is managed at the INBO on +Google Drive. Create a csv export of that file, and make sure it is \code{,} +delimited. } \examples{ \dontrun{ diff --git a/man/load_tracks_file.Rd b/man/load_tracks_file.Rd index 27527aa..300ca43 100644 --- a/man/load_tracks_file.Rd +++ b/man/load_tracks_file.Rd @@ -2,20 +2,20 @@ % Please edit documentation in R/extract.R \name{load_tracks_file} \alias{load_tracks_file} -\title{Load file containing bird tracking data} +\title{Load file containing bird tracking data.} \usage{ load_tracks_file(filename) } \arguments{ \item{filename}{The file containing bird tracking data in csv -format. (','-delimited, header included)} +format. (','-delimited, header included).} } \value{ -A data table (not a data frame!) containing the tracking data +A data table (not a data frame!) containing the tracking data. } \description{ -Load a file containing bird tracking data. This file can -be obtained by requesting a dump from the UvA-BiTS virtual lab. +Load a file containing bird tracking data. This file can be obtained by +requesting a dump from the UvA-BiTS virtual lab. } \examples{ \dontrun{ diff --git a/man/profiling_L1.Rd b/man/profiling_L1.Rd index a75c221..dc71706 100644 --- a/man/profiling_L1.Rd +++ b/man/profiling_L1.Rd @@ -2,7 +2,7 @@ % Please edit documentation in R/profiling.R \name{profiling_L1} \alias{profiling_L1} -\title{Profile UvA-BiTS ETL processing steps (Level 1)} +\title{Profile UvA-BiTS ETL processing steps (Level 1).} \usage{ profiling_L1(tracks_file, birds_file) } @@ -10,14 +10,14 @@ profiling_L1(tracks_file, birds_file) \item{tracks_file}{CSV file containing tracking data used for profiling. Don't use a file that is too big (because it will take some time), but don't make it too small either (because that can introduces biases that are not -representative)} +representative).} \item{birds_file}{CSV file containing bird tracking metadata.} } \value{ -Data.Frame with two columns: "step" and "timing" +Data.Frame with two columns: \code{step} and \code{timing}. } \description{ -Profile the different processing steps in the bird-trakcing-etl -package to find bottlenecks. +Profile the different processing steps in the bird-trakcing-etl package to +find bottlenecks. } diff --git a/man/raster_join.Rd b/man/raster_join.Rd index 426ebf4..1da0a64 100644 --- a/man/raster_join.Rd +++ b/man/raster_join.Rd @@ -2,20 +2,20 @@ % Please edit documentation in R/enrich.R \name{raster_join} \alias{raster_join} -\title{Raster join} +\title{Raster join.} \usage{ raster_join(dt, raster_data) } \arguments{ -\item{dt}{Data table with tracking data. Geospatial points are created based on the -latitude and longitude field and WGS84 datum is expected.} +\item{dt}{Data table with tracking data. Geospatial points are created based +on the \code{latitude} and \code{longitude} field and WGS84 datum is expected.} -\item{raster_data}{A raster data object. See the package "raster".} +\item{raster_data}{A raster data object. See the package \code{raster}.} } \value{ -nothing. The value of the raster for every point is added to the data -table in place +Nothing. The value of the raster for every point is added to the data +table in place. } \description{ -Join tracks with raster data +Join tracks with raster data. } diff --git a/man/read_raster_data.Rd b/man/read_raster_data.Rd index 6f2633c..1f748fd 100644 --- a/man/read_raster_data.Rd +++ b/man/read_raster_data.Rd @@ -2,22 +2,22 @@ % Please edit documentation in R/extract.R \name{read_raster_data} \alias{read_raster_data} -\title{Read raster data} +\title{Read raster data.} \usage{ read_raster_data(filename, data.CRS = "+init=epsg:4326") } \arguments{ -\item{filename}{Name of the file containing raster data} +\item{filename}{Name of the file containing raster data.} -\item{data.CRS}{Coordinate Reference System of the data} +\item{data.CRS}{Coordinate Reference System of the data.} } \value{ -raster data as RasterLayer class +Raster data as RasterLayer class. } \description{ -Read raster data using the raster package. By default -this function will set the CRS of this data to EPSG4326 (WGS 84). -Use the data.CRS parameter to override this. +Read raster data using the raster package. By default this function will set +the CRS of this data to EPSG4326 (WGS 84). Use the data.CRS parameter to +override this. } \examples{ \dontrun{ diff --git a/man/read_raster_legend.Rd b/man/read_raster_legend.Rd index 9adaa95..04e0c68 100644 --- a/man/read_raster_legend.Rd +++ b/man/read_raster_legend.Rd @@ -2,20 +2,20 @@ % Please edit documentation in R/extract.R \name{read_raster_legend} \alias{read_raster_legend} -\title{Read the raster legend} +\title{Read the raster legend.} \usage{ read_raster_legend(filename) } \arguments{ -\item{filename}{Name of the csv file containing the raster legend} +\item{filename}{Name of the csv file containing the raster legend.} } \value{ -a data table containing the raster legend +A data table containing the raster legend. } \description{ -Read the raster legend. The legend is expected to contain two columns: -`id` containing the actual values used in the raster layer, and `value` which contains -the labels. +Read the raster legend. The legend is expected to contain two +columns: \code{id} containing the actual values used in the raster layer, and +\code{value} which contains the labels. } \examples{ \dontrun{ diff --git a/man/sex_choices.Rd b/man/sex_choices.Rd index e04cd21..8ab403a 100644 --- a/man/sex_choices.Rd +++ b/man/sex_choices.Rd @@ -3,12 +3,12 @@ \docType{data} \name{sex_choices} \alias{sex_choices} -\title{Sex choices} +\title{Sex choices.} \format{character vector} \usage{ sex_choices } \description{ -Allowed values for the sex column in bird metadata +Allowed values for the sex column in bird metadata. } \keyword{datasets} diff --git a/man/species_choices.Rd b/man/species_choices.Rd index 73b242b..dba718d 100644 --- a/man/species_choices.Rd +++ b/man/species_choices.Rd @@ -3,12 +3,12 @@ \docType{data} \name{species_choices} \alias{species_choices} -\title{Species choices} +\title{Species choices.} \format{character vector} \usage{ species_choices } \description{ -Allowed values for the species column in bird metadata +Allowed values for the species column in bird metadata. } \keyword{datasets} diff --git a/man/suncalc.custom.Rd b/man/suncalc.custom.Rd index d0ccde8..b8b7d72 100644 --- a/man/suncalc.custom.Rd +++ b/man/suncalc.custom.Rd @@ -2,24 +2,24 @@ % Please edit documentation in R/enrich.R \name{suncalc.custom} \alias{suncalc.custom} -\title{Calculate sunrise and sunset} +\title{Calculate sunrise and sunset.} \usage{ suncalc.custom(dates, Lat, Long) } \arguments{ -\item{dates}{vector containing POSIX dates} +\item{dates}{Vector containing POSIX dates.} -\item{Lat}{Latitudes in WGS84} +\item{Lat}{Latitudes in WGS84.} -\item{Long}{Longitudes in WGS84} +\item{Long}{Longitudes in WGS84.} } \value{ -named list with elements "sunrise" and "sunset" +Named list with elements \code{sunrise} and \code{sunset}. } \description{ -This function calculate the sunrise and sunset in UTC -for a given location and date. Function was slightly modified but inspired -from this post: http://www.r-bloggers.com/approximate-sunrise-and-sunset-times/ +This function calculate the sunrise and sunset in UTC for a given location +and date. Function was slightly modified but inspired from this post: +\url{http://www.r-bloggers.com/approximate-sunrise-and-sunset-times/} } \examples{ { diff --git a/man/tracks_validated.Rd b/man/tracks_validated.Rd index dd8c56b..68ce882 100644 --- a/man/tracks_validated.Rd +++ b/man/tracks_validated.Rd @@ -3,7 +3,7 @@ \docType{data} \name{tracks_validated} \alias{tracks_validated} -\title{Tracks validated} +\title{Tracks validated.} \format{data table} \usage{ tracks_validated diff --git a/man/validate_bird_data.Rd b/man/validate_bird_data.Rd index 9685ca6..4bdd44a 100644 --- a/man/validate_bird_data.Rd +++ b/man/validate_bird_data.Rd @@ -2,16 +2,16 @@ % Please edit documentation in R/extract.R \name{validate_bird_data} \alias{validate_bird_data} -\title{Validate bird data} +\title{Validate bird data.} \usage{ validate_bird_data(bird_data) } \arguments{ -\item{bird_data}{The bird metadata as a data table} +\item{bird_data}{The bird metadata as a data table.} } \value{ -validated bird metadata as a data table if no errors are found. +Validated bird metadata as a data table if no errors are found. } \description{ -Validate the bird metadata +Validate the bird metadata. } diff --git a/man/validate_tracks_data.Rd b/man/validate_tracks_data.Rd index 7604f62..8e3b5f7 100644 --- a/man/validate_tracks_data.Rd +++ b/man/validate_tracks_data.Rd @@ -2,19 +2,19 @@ % Please edit documentation in R/extract.R \name{validate_tracks_data} \alias{validate_tracks_data} -\title{Validate tracking data} +\title{Validate tracking data.} \usage{ validate_tracks_data(tracks_data) } \arguments{ -\item{tracks_data}{The tracking data as a data table} +\item{tracks_data}{The tracking data as a data table.} } \value{ -validated tracking data as a data table if no errors are found. +Validated tracking data as a data table if no errors are found. } \description{ -Validate the data coming either from a csv file or -from the UvA-BiTS virtual lab directly. +Validate the data coming either from a csv file or from the UvA-BiTS virtual +lab directly. } \examples{ \dontrun{