Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue Extending Demo Code to Full Dataset #1

Open
obry0017 opened this issue Nov 13, 2015 · 0 comments
Open

Issue Extending Demo Code to Full Dataset #1

obry0017 opened this issue Nov 13, 2015 · 0 comments

Comments

@obry0017
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant