@@ -6,20 +6,19 @@ library(XML)
66# '
77# ' @param file_path A character string specifying the path to the TCX file.
88# ' @return A list containing the computed activity metrics, including the activity type.
9- # ' @import XML
109# ' @importFrom XML xmlTreeParse xmlRoot getNodeSet xmlGetAttr xmlValue
1110# ' @export
1211TCXRead <- function (file_path ) {
13- doc <- xmlTreeParse(file_path , useInternalNodes = TRUE )
14- root <- xmlRoot(doc )
12+ doc <- XML :: xmlTreeParse(file_path , useInternalNodes = TRUE )
13+ root <- XML :: xmlRoot(doc )
1514
16- activities <- getNodeSet(root , " //ns:Activities/ns:Activity" , namespaces = c(ns = " http://www.garmin.com/xmlschemas/TrainingCenterDatabase/v2" ))
15+ activities <- XML :: getNodeSet(root , " //ns:Activities/ns:Activity" , namespaces = c(ns = " http://www.garmin.com/xmlschemas/TrainingCenterDatabase/v2" ))
1716
1817 activity_data <- lapply(activities , function (activity ) {
1918 # Get the activity type (Sport) from the activity node
20- activity_type <- xmlGetAttr(activity , " Sport" )
19+ activity_type <- XML :: xmlGetAttr(activity , " Sport" )
2120
22- laps <- getNodeSet(activity , " ns:Lap" , namespaces = c(ns = " http://www.garmin.com/xmlschemas/TrainingCenterDatabase/v2" ))
21+ laps <- XML :: getNodeSet(activity , " ns:Lap" , namespaces = c(ns = " http://www.garmin.com/xmlschemas/TrainingCenterDatabase/v2" ))
2322 lap_data <- lapply(laps , parse_lap )
2423
2524 # Return the lap data along with activity type
@@ -86,6 +85,7 @@ TCXRead <- function(file_path) {
8685 ))
8786}
8887
88+
8989# ' Parse a Lap from a TCX File
9090# '
9191# ' Extracts data from a lap within a TCX file, including time, distance, altitude, speed, power, cadence, and heart rate.
@@ -132,7 +132,6 @@ parse_lap <- function(lap) {
132132 ))
133133}
134134
135-
136135# ' Parse a Trackpoint from a TCX File
137136# '
138137# ' Extracts data from a trackpoint, including altitude, distance, speed, power, cadence, and heart rate.
0 commit comments