Closed mdsumner closed 5 years ago
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(data, x, y, t, g, ...)
as the column names.
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 https://github.com/Trackage/trip/issues/29
thanks @ianjonsen ;)
This is completely hopeless as a way of working:
Make some easy improvements to help using trip with the current functionality.