Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ## Create a data.frame of 10-minute intervals stored as POSIXct
- ## You can convert most times to POSIXct using as.POSIXct if they are not already that format
- lizard <- data.frame(time=seq(from=as.POSIXct('2015-01-01 00:00:00'), to=as.POSIXct('2015-01-02 00:00:00'), by=10*60))
- ## Randomly eliminate rows with probability of 15% that a given row is eliminated to create gaps
- lizard$keep = runif(nrow(lizard))
- lizard <- lizard[lizard$keep <= .85, c('time'), drop=FALSE] ## drop arg used to kepe it a dataframe
- ## Random lat / lon data:
- lizard$Lat = runif(nrow(lizard)) ## runif is random uniform
- lizard$Lon = runif(nrow(lizard))
- ## We initialize to NA; the distance variable for row i will represent the distance between row i-1 and i;
- ## row 1 will not have a meaningful value
- lizard$distance <- NA
- lizard$distance[2:nrow(lizard)] <- distanceTrack(lizard$Lat, lizard$Lon)
- lizard$isContiguous <- TRUE ## initialize a variable to determine if the data is at 10-min interval
- lizard$isContiguous[2:nrow(lizard)] <- (as.numeric(lizard$time[2:nrow(lizard)] - lizard$time[1:nrow(lizard) - 1]) == 10)
- lizard <- lizard[lizard$isContiguous, ] ## filter
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement