-
Notifications
You must be signed in to change notification settings - Fork 2
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
easy trip constructors #21
Comments
Early stab here: https://github.com/Trackage/trip/blob/aes/R/gg-aesthetics.R Still need:
|
I think this is waaay better, also toying with rlang approach to catpure trip.grouped_df <- function(obj, ..., crs = NULL) {
tor <- c(names(obj)[3], dplyr::group_vars(obj))
if (!inherits(obj[[tor[1]]], "POSIXct")) stop(sprintf("3rd column [%s] must be date-time", tor[1]))
obj <- dplyr::ungroup(obj)
sp::coordinates(obj) <- names(obj)[1:2]
if (!is.null(crs)) sp::proj4string(obj)
trip(obj, tor)
}
library(dplyr)
#>
#> Attaching package: 'dplyr'
#> The following objects are masked from 'package:stats':
#>
#> filter, lag
#> The following objects are masked from 'package:base':
#>
#> intersect, setdiff, setequal, union
library(trip)
#> Loading required package: sp
d <- tibble::as_tibble(walrus818)
d <- d %>% group_by(Deployment)
d <- d %>% select(X_AED170_70,Y_AED170_70, DataDT, everything())
tr <- trip.grouped_df(d)
## the really neat part is that this grouped data frame is directly useable with
## ggplot2 as-is
library(ggplot2)
ggplot(d, aes(X_AED170_70, Y_AED170_70, col = DataDT)) + geom_path() Created on 2019-04-05 by the reprex package (v0.2.1) |
Pay heed to feedback here: https://gist.github.com/mdsumner/e2fc9d282d82bb3d5a2ea55dd2426874#gistcomment-2881887 |
This is done!
Also added mousetrap, amt and trackeR support see #29 |
thanks @ianjonsen ;) |
This is completely hopeless as a way of working:
Make some easy improvements to help using trip with the current functionality.
The text was updated successfully, but these errors were encountered: