Trackage / trip

trip package development
http://trackage.github.io/trip/
12 stars 2 forks source link

allow sf to use the select(time, ID, everything()) idiom #31

Closed mdsumner closed 5 years ago

mdsumner commented 5 years ago

The various trip methods need review, they could be cleaned up a bit so that trip.sf simply leverages the same as used for df.

mdsumner commented 5 years ago

works now

library(trip)
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(sf)
#> Linking to GEOS 3.7.0, GDAL 2.4.0, PROJ 5.2.0
w <- sf::st_as_sf(walrus818)[1:1000, ]

dplyr::select(w, DataDT, Deployment, everything()) %>% trip()
#> 
#> Object of class trip
#>   tripID ("Deployment") No.Records startTime ("DataDT")
#> 1                   353        160  2009-09-15 04:00:00
#> 2                   354        813  2009-09-16 04:00:00
#> 3                   355         27  2009-09-16 04:00:00
#>    endTime ("DataDT")  tripDuration
#> 1 2009-09-30 19:00:00   15.625 days
#> 2 2009-10-20 00:00:00 33.83333 days
#> 3 2009-09-17 06:00:00 1.083333 days
#> 
#>   data.columns data.class                  
#> 1       DataDT    POSIXct **trip DateTime**
#> 2   Deployment    integer **trip ID**      
#> 3          Wet    integer                  
#> 4       Forage    integer

w %>% trip(c("DataDT", "Deployment"))
#> 
#> Object of class trip
#>   tripID ("Deployment") No.Records startTime ("DataDT")
#> 1                   353        160  2009-09-15 04:00:00
#> 2                   354        813  2009-09-16 04:00:00
#> 3                   355         27  2009-09-16 04:00:00
#>    endTime ("DataDT")  tripDuration
#> 1 2009-09-30 19:00:00   15.625 days
#> 2 2009-10-20 00:00:00 33.83333 days
#> 3 2009-09-17 06:00:00 1.083333 days
#> 
#>   data.columns data.class                  
#> 1   Deployment    integer **trip ID**      
#> 2       DataDT    POSIXct **trip DateTime**
#> 3          Wet    integer                  
#> 4       Forage    integer

Created on 2019-04-15 by the reprex package (v0.2.1)