Code Monkey home page Code Monkey logo

swarm's Introduction

swaRm - R package for processing individual and collective movement data

R-CMD-check Codecov test coverage CRAN status CRANLOGS downloads

Description

swaRm is a R package meant to standardize and accelerate the processing of data describing the movements of animal and human groups (e.g. fish schools, bird flocks).

swaRm is a work in progress. Functions are not yet in a stable state and are likely to change as the package gets developed.

swarm's People

Contributors

sjmgarnier avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

swarm's Issues

Issue Extending Demo Code to Full Dataset

After running the tutorial found here: http://rpubs.com/sjmgarnier/swaRm I tried to apply the code in section 6.1 to all of my raw GPS files. I found that there were several issues that were causing error messages. Most of these issues relate to the fact that my raw GPS data are in a slightly different format than the example data. The other issue is that some error checking needs to take place before the various functions are applied to these data. The specific issues are listed below.

  1. My raw data are stored as .txt files, not .csv

  2. My raw data have 10 columns rather than 4

  3. The columns are named "V1", "V2"..."V10" rather than "lat", "lon", etc.

  4. The date is in the format: DD/MM/YYYY rather than YYYY-MM-DD

  5. The file names have different separators than those in the example datasets so the id names automatically generated from the file path were not correct (example file path: "/Volumes/My Passport/Lisa/GPS Data/GPS 09_18_2015_Collar 11.txt")

  6. There are some times in the full dataset that are errors and exceed the values of typical time data (ex. 96:01:51). Thus, when combined with the date column in the makeTraj function, these values become NA's. This then becomes an issue for the remaining functions, such as completeTraj, which look for the minimum and maximum values in the time column. Since there are NA values present in this column, I receive the error message:

"Error in seq.int(0, to0 - from, by) : 'to' cannot be NA, NaN or infinite"

In order to solve issues 1-5, I altered the first few lines of the code from section 6.1 to the following:

trajs <- lapply(filePaths, function(path) {
dat <- as.data.table(read.table(path))
dat <- select(dat,V1,V2,V3,V4)
dat <- rename(dat, date = V1, time = V2, lon = V3, lat = V4)
makeTraj2(x = dat$lon, y = dat$lat, date = dat$date, time = dat$time,
id = gsub(".__|.txt._", "\1", path), geo = TRUE)}) %>%

Here I use the makeTraj2 function which is the same as the makeTraj function except that in the third line from the bottom I changed the order of "ymd" to "dmy" (traj$time <- lubridate::dmy_hms(paste(date, time), tz = tz))

At this point I have properly formatted data except for the fact that any time errors have been converted to NAs.

Attached are subsets of two datasets that exemplify these issues. A time error is seen in the file Example Data_Collar 4.

Example Data_Collar 1.txt
Example Data_Collar 4.txt

suggested function for swaRm

It would be useful to have a function that enables the user to define a point, a line and/or a polygon (x, y coordinates) in the environment and calculate each individual's distance to this fixed area at each time stamp. It's a measure I find I constantly need, especially in experiments with foraging patches. It could enable me to look at the order in which individuals arrive at/leave a food patch, how long each individual remains within the patch etc, which can subsequently help identify key individuals driving group movement.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.