The idiomatic way is to parse the xml:
f <- function(i) {
library(XML)
library(stringr)
x <- trip[i,]
segment <- paste0(x$Chrom,":",x$Lbase,",",x$Rbase)
url <- paste0("http://genome.ucsc.edu/cgi-bin/das/hg19/dna?segment=",segment)
doc <- xmlInternalTreeParse(url)
return(str_extract(xmlValue(doc["//DNA"][[1]]),"[a-z]+"))
}
trip$triplet=sapply(1:nrow(trip),f)
trip
# Chrom Position Gene.Sym Ref Variant Lbase Rbase triplet
# 1 chr1 888639 NOC2L T C 888638 888640 ctt
# 2 chr1 889158 NOC2L G C 889157 889159 cga
# 3 chr1 889159 NOC2L A C 889158 889160 gaa
# 4 chr1 982941 AGRN T C 982940 982942 ctc
# 5 chr1 1888193 KIAA1751 C A 1888192 1888194 ccg
# 6 chr1 3319632 PRDM16 G A 3319631 3319633 tgc
If your data frame is large (many rows) this is likely to take a very long time, and you may get locked out of the server. It would be better to download multiple sections at once and then parse that in R, but I'm not familiar with the API.