convert to and from trackeR
#' @title Coerce methods #' @name as #' @rdname coerce-methods #' @aliases coerce,sftrack #' # setAs("sftrack", "trackeRdata",function(from)# sftrack_to_trackeR(from,...)
# S3 method for trackeRdata as_sftrack(data, ..., include_units = FALSE) # S3 method for trackeRdata as_sftraj(data, ..., include_units = FALSE) sftrack_to_trackeR(data, sport, ...) sftraj_to_trackeR(data, sport, ...)
data | the data either sftrack,sftraj,or trackeRdata class to convert |
---|---|
... | More arguments to be passed to `trackerData()`, please see its help file for more information. |
include_units | whether to add the units() to the ends of the colnames so they may be retained when converting to sftrack |
sport | (for amt conversions) The sport (cycling, running, swimming) to data is taken from |
#>#> #>#>#> #>#>#> #>#> #>#>#> #>filepath <- system.file("extdata/tcx/", "2013-06-01-183220.TCX.gz", package = "trackeR") runDF <- readTCX(file = filepath, timezone = "GMT") runTr0 <- trackeRdata(runDF)#> Warning: Observations with duplicated time stamps have been removed.#> sftrack (*locations*) with 6 features and 16 fields #> geometry: "geometry" (XY, CRS: +proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs) #> timestamps: "time" (integer) #> groupings: "sft_group" (*id*, *session*) #> ------------------------------- #> session time latitude longitude altitude distance heart_rate #> 1 1 2013-06-01 17:32:15 50.82099 -1.703626 83.40002 0 NA #> 2 1 2013-06-01 17:32:15 50.82099 -1.703626 83.40002 0 NA #> 3 1 2013-06-01 17:32:15 50.82099 -1.703626 83.40002 0 NA #> 4 1 2013-06-01 17:32:16 50.82099 -1.703626 83.40002 0 NA #> 5 1 2013-06-01 17:32:16 50.82099 -1.703626 83.40002 0 NA #> 6 1 2013-06-01 17:32:17 50.82099 -1.703626 83.40002 0 NA #> speed cadence_running cadence_cycling power temperature pace #> 1 0 NA NA NA NA NA #> 2 0 NA NA NA NA NA #> 3 0 NA NA NA NA NA #> 4 0 NA NA NA NA NA #> 5 0 NA NA NA NA NA #> 6 0 NA NA NA NA NA #> cumulative_elevation_gain sft_group geometry #> 1 0.02411786 (id: id1, session: 1) POINT (50.82099 -1.703626) #> 2 0.04627898 (id: id1, session: 1) POINT (50.82099 -1.703626) #> 3 0.06643583 (id: id1, session: 1) POINT (50.82099 -1.703626) #> 4 0.08454433 (id: id1, session: 1) POINT (50.82099 -1.703626) #> 5 0.10056382 (id: id1, session: 1) POINT (50.82099 -1.703626) #> 6 0.11445709 (id: id1, session: 1) POINT (50.82099 -1.703626)#> sftraj (*steps*) with 6 features and 16 fields #> geometry: "geometry" (XY, CRS: +proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs) #> timestamps: "time" (integer) #> groupings: "sft_group" (*id*, *session*) #> ------------------------------- #> session time latitude longitude #> 1 1 (2013-06-01 17:32:15 --> 2013-06-01 17:32:15) 50.82099 -1.703626 #> 2 1 (2013-06-01 17:32:15 --> 2013-06-01 17:32:15) 50.82099 -1.703626 #> 3 1 (2013-06-01 17:32:15 --> 2013-06-01 17:32:16) 50.82099 -1.703626 #> 4 1 (2013-06-01 17:32:16 --> 2013-06-01 17:32:16) 50.82099 -1.703626 #> 5 1 (2013-06-01 17:32:16 --> 2013-06-01 17:32:17) 50.82099 -1.703626 #> 6 1 (2013-06-01 17:32:17 --> 2013-06-01 17:32:17) 50.82099 -1.703626 #> altitude distance heart_rate speed cadence_running cadence_cycling power #> 1 83.40002 0 NA 0 NA NA NA #> 2 83.40002 0 NA 0 NA NA NA #> 3 83.40002 0 NA 0 NA NA NA #> 4 83.40002 0 NA 0 NA NA NA #> 5 83.40002 0 NA 0 NA NA NA #> 6 83.40002 0 NA 0 NA NA NA #> temperature pace cumulative_elevation_gain sft_group #> 1 NA NA 0.02411786 (id: id1, session: 1) #> 2 NA NA 0.04627898 (id: id1, session: 1) #> 3 NA NA 0.06643583 (id: id1, session: 1) #> 4 NA NA 0.08454433 (id: id1, session: 1) #> 5 NA NA 0.10056382 (id: id1, session: 1) #> 6 NA NA 0.11445709 (id: id1, session: 1) #> geometry #> 1 LINESTRING (50.82099 -1.703... #> 2 LINESTRING (50.82099 -1.703... #> 3 LINESTRING (50.82099 -1.703... #> 4 LINESTRING (50.82099 -1.703... #> 5 LINESTRING (50.82099 -1.703... #> 6 LINESTRING (50.82099 -1.703...# convert back sftrack_to_trackeR(my_sftrack, sport = "running")#> A trackeRdata object #> Sports: running #> #> Training coverage: from 2013-06-01 19:32:10 to 2013-06-01 20:38:01 #> Number of sessions: 1 #> Training duration: 1.1 h #> #> Units #> #> latitude degree cycling #> longitude degree cycling #> altitude m cycling #> distance m cycling #> heart_rate bpm cycling #> speed m_per_s cycling #> cadence_cycling rev_per_min cycling #> power W cycling #> temperature C cycling #> pace min_per_km cycling #> duration min cycling #> latitude degree running #> longitude degree running #> altitude m running #> distance m running #> heart_rate bpm running #> speed m_per_s running #> cadence_running steps_per_min running #> temperature C running #> pace min_per_km running #> duration min running #> latitude degree swimming #> longitude degree swimming #> altitude m swimming #> distance m swimming #> heart_rate bpm swimming #> speed m_per_s swimming #> temperature C swimming #> pace min_per_km swimming #> duration min swimming