You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
My raw data are stored as .txt files, not .csv
My raw data have 10 columns rather than 4
The columns are named "V1", "V2"..."V10" rather than "lat", "lon", etc.
The date is in the format: DD/MM/YYYY rather than YYYY-MM-DD
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")
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.
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.
My raw data are stored as .txt files, not .csv
My raw data have 10 columns rather than 4
The columns are named "V1", "V2"..."V10" rather than "lat", "lon", etc.
The date is in the format: DD/MM/YYYY rather than YYYY-MM-DD
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")
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
The text was updated successfully, but these errors were encountered: