Вам действительно нужен внешний пакет?
dat <- read.table(header=TRUE, stringsAsFactors=FALSE, text='
DEVICE_ID LAT LONGITUDE DATE TIME
150211559 12.920818 77.600197 02-01-17 0:00:00
150211559 12.914159 77.600037 02-01-17 0:01:39
150211559 12.919819 77.600189 02-01-17 0:00:10
150211559 12.919434 77.600174 02-01-17 0:00:20
150211559 12.918937 77.60009 02-01-17 0:00:29
150211559 12.914159 77.600037 02-01-17 0:01:49
150211559 12.918482 77.600136 02-01-17 0:00:39
150211559 12.917423 77.60009 02-01-17 0:00:49')
pre <- '<?xml version="1.0" encoding="utf-8" standalone="yes"?> <gpx version="1.1" creator="GPS Visualizer http://www.gpsvisualizer.com/" xmlns="http://www.topografix.com/GPX/1/1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.topografix.com/GPX/1/1 http://www.topografix.com/GPX/1/1/gpx.xsd"> <trk> <name>test1</name> <trkseg>'
post <- '</trkseg> </trk> </gpx>'
dat$dt <- format(as.POSIXct(paste(dat$DATE, dat$TIME), format="%m-%d-%y %H:%M:%S"),
format="%Y-%m-%dT%H:%M:%SZ", tz="UTC")
cat(paste(
c(pre,
mapply(function(lat, lon, datetime) {
sprintf('<trkpt lat="%f" lon="%f">
<time>%s</time>
</trkpt>', lat, lon, datetime)
}, dat$LAT, dat$LONGITUDE, dat$dt),
post, "\n"),
collapse="\n"))
# <?xml version="1.0" encoding="utf-8" standalone="yes"?> <gpx version="1.1" creator="GPS Visualizer http://www.gpsvisualizer.com/" xmlns="http://www.topografix.com/GPX/1/1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.topografix.com/GPX/1/1 http://www.topografix.com/GPX/1/1/gpx.xsd"> <trk> <name>test1</name> <trkseg>
# <trkpt lat="12.920818" lon="77.600197">
# <time>2017-02-01T08:00:00Z</time>
# </trkpt>
# <trkpt lat="12.914159" lon="77.600037">
# <time>2017-02-01T08:01:39Z</time>
# </trkpt>
# <trkpt lat="12.919819" lon="77.600189">
# <time>2017-02-01T08:00:10Z</time>
# </trkpt>
# <trkpt lat="12.919434" lon="77.600174">
# <time>2017-02-01T08:00:20Z</time>
# </trkpt>
# <trkpt lat="12.918937" lon="77.600090">
# <time>2017-02-01T08:00:29Z</time>
# </trkpt>
# <trkpt lat="12.914159" lon="77.600037">
# <time>2017-02-01T08:01:49Z</time>
# </trkpt>
# <trkpt lat="12.918482" lon="77.600136">
# <time>2017-02-01T08:00:39Z</time>
# </trkpt>
# <trkpt lat="12.917423" lon="77.600090">
# <time>2017-02-01T08:00:49Z</time>
# </trkpt>
# </trkseg> </trk> </gpx>
(Вы, вероятно, должны сохранить в файл вместо cat(...)
, я просто хотел показать это.)