Skip to content

Commit

Permalink
Merge branch 'experimental'
Browse files Browse the repository at this point in the history
  • Loading branch information
steffilazerte committed Nov 4, 2017
2 parents 8a6c4e1 + 579c0e3 commit 7aaf78f
Show file tree
Hide file tree
Showing 63 changed files with 82,920 additions and 81,930 deletions.
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
Package: feedr
Type: Package
Title: Transforming Raw RFID Data
Version: 0.9.0
Date: 2017-06-05
Version: 0.9.1
Date: 2017-11-03
Authors@R: person("LaZerte", "Stefanie E", email = "[email protected]", role = c("aut","cre"))
URL: https://github.com/animalnexus/feedr
Description: Load, clean, transform, and visualize raw RFID data for looking at a variety of
Expand Down
18 changes: 12 additions & 6 deletions R/data.R
Original file line number Diff line number Diff line change
@@ -1,31 +1,37 @@
#' Finche visits to RFID-enabled feeders
#' Finch visits to RFID-enabled feeders
#'
#' A small dataset containing raw reads of finches visiting feeders (RFID
#' loggers) on Thompson Rivers University campus in Kamloops, BC, Canada
#'
#' @format A data frame with 412 rows and 7 variables:
#' @format A data frame with 412 rows and 10 variables:
#' \describe{
#' \item{animal_id}{Unique RFID tag attached to a finch}
#' \item{date}{Date of the read}
#' \item{time}{Time of read}
#' \item{logger_id}{Unique id of logger where read was made}
#' \item{species}{Individual species}
#' \item{age}{Individual age}
#' \item{sex}{Individual sex, if known}
#' \item{site_name}{Site name of the observation}
#' \item{lat}{Latitude}
#' \item{lon}{Longitude}}
"finches"

#' Large dataset of finche visits to RFID-enabled feeders
#' Large dataset of finch visits to RFID-enabled feeders
#'
#' A large dataset containing raw reads of finches visiting feeders (RFID
#' loggers) on Thompson Rivers University campus in Kamloops, BC, Canada
#'
#' @format A data frame with 42708 rows and 7 variables:
#' @format A data frame with 42708 rows and 10 variables:
#' \describe{
#' \item{animal_id}{Unique RFID tag attached to a finch}
#' \item{date}{Date of the read}
#' \item{time}{Time of read}
#' \item{logger_id}{Unique id of logger where read was made}
#' \item{species}{Individual species}
#' \item{age}{Individual age}
#' \item{sex}{Individual sex, if known}
#' \item{site_name}{Site name of the observation}
#' \item{lat}{Latitude}
#' \item{lon}{Longitude}}
"finches_lg"
Expand All @@ -35,13 +41,13 @@
#' A dataset containing raw reads of black-capped chickadees visiting
#' RFID-enabled feeders (loggers) in Prince George, BC, Canada
#'
#' @format A data frame with 26718 rows and 7 variables:
#' @format A data frame with 26,753 rows and 10 variables:
#' \describe{
#' \item{animal_id}{Unique RFID tag attached to a chickadee}
#' \item{date}{Date of the read}
#' \item{time}{Time of read}
#' \item{logger_id}{Unique id of logger where read was made}
#' \item{experiment}{Which experiment (site) the data was collected at}
#' \item{date}{Date of read}
#' \item{lat}{Latitude of logger location}
#' \item{lon}{Longitude of logger location}}
"chickadees"
2 changes: 1 addition & 1 deletion R/errorchecks.R
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ check_input <- function(d, input = "lon", options = c("lon", "longitude", "long"
c <- utils::combn(n, 2)
if(ncol(c) < 10) {
for(i in 1:ncol(c)) {
if(!isTRUE(all.equal(d[, c[1, i]], d[, c[2, i]]))) {
if(!isTRUE(all.equal(d[, c[1, i]][[1]], d[, c[2, i]][[1]]))) {
stop("There are multiple ", input, " columns which are not equivalent\n(expects ", input, " to be one of ", paste0(options, collapse = ", "), ", but ignores case")
}
}
Expand Down
2 changes: 1 addition & 1 deletion R/feedr.R
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ if(getRversion() >= "2.15.1")
"site_name", "dataaccess", "count", "start", "x", "fill", "facet", "end", "y", "counts_sum", "temp", "engl_name", "val", "id", "f", "arg", "title", "lab", "site_id",

# Convert functions
"item.number",
"item.number", "midnight", "time_sec", "time_rad", "data",

# piping requires '.' at times
".")
Expand Down
6 changes: 3 additions & 3 deletions R/load.R
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ load_raw <- function(r_file,
# Convert times
r$time <- lubridate::parse_date_time(paste(r$date, r$time), orders = time_format, tz = tz)
if(tz_disp != tz) r$time <- lubridate::with_tz(r$time, tz_disp)
r$date <- as.Date(r$time)
r$date <- as.Date(r$time, tz = lubridate::tz(r$time))

# Reorder columns
cols <- names(r)[names(r) %in% c("animal_id", "date", "time", "logger_id", "lat", "lon")]
Expand Down Expand Up @@ -535,7 +535,7 @@ load_format <- function(r, tz = Sys.timezone(), tz_disp = NULL, dst = FALSE, tim
if("time" %in% names(r)) {
r$time <- lubridate::parse_date_time(r$time, orders = time_format, tz = tz, truncated = 1)
if(tz != tz_disp) r$time <- lubridate::with_tz(r$time, tz_disp)
r$date <- as.Date(r$time)
r$date <- as.Date(r$time, tz = lubridate::tz(r$time))
}

# Make sure all factors are factors:
Expand All @@ -549,7 +549,7 @@ load_format <- function(r, tz = Sys.timezone(), tz_disp = NULL, dst = FALSE, tim
}

# Reorder columns
cols <- c("animal_id", "time", "logger_id")
cols <- c("animal_id", "date", "time", "logger_id")
cols <- cols[which(cols %in% names(r))]
r <- r[, c(cols, names(r)[!(names(r) %in% cols)])]

Expand Down
4 changes: 2 additions & 2 deletions R/transformations.R
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ visits <- function(r, bw = 3, allow_imp = FALSE, bw_imp = 2, na_rm = FALSE, pass
dplyr::ungroup() %>%
dplyr::mutate(animal_n = length(unique(animal_id)), # Get sample sizes
logger_n = length(unique(logger_id)),
date = as.Date(start))
date = as.Date(start, tz = lubridate::tz(start)))

# Set timezone attributes
attr(v$start, "tzone") <- tz
Expand Down Expand Up @@ -445,7 +445,7 @@ presence_single <- function(v1, bw = bw){

## Create the presence data frame.
p <- tibble::data_frame(animal_id = v1$animal_id[1],
date = as.Date(v1$start_orig[v1$start == TRUE]),
date = v1$date[v1$start == TRUE],
logger_id = v1$logger_id[v1$start == TRUE],
start = v1$start_orig[v1$start == TRUE],
end = v1$end_orig[v1$end == TRUE],
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
[![Travis-Ci Build Status](https://travis-ci.org/animalnexus/feedr.svg?branch=master)](https://travis-ci.org/animalnexus/feedr)

[![AppVeyor Build Status](https://ci.appveyor.com/api/projects/status/github/animalnexus/feedr?branch=master&svg=true)](https://ci.appveyor.com/project/animalnexus/feedr)

# feedr

`feedr` is a package for [R](https://www.r-project.org/). This collection of functions is designed to load, transform and visualize RFID data created when pit-tagged animals are detected by RFID loggers associated with static stations (e.g., seed-feeders, nestboxes, nectar-feeders, etc.).
Expand Down
Loading

0 comments on commit 7aaf78f

Please sign in to comment.