[R] Issue with concatenation of URL losing

Oliver Morris om2468 at hotmail.com
Wed Jan 24 18:03:51 CET 2018


Thank you for your help in advance.


I am trying to pull some data back from a web service


library(httr)
sample2 <- GET("https://elevation.mapzen.com/height?json={\"range\":false,\"shape\":[{\"lat\":40.7,\"lon\":-76.5}]}&api_key=mycode")
result2 <- content(sample2)
height <- result2$height[[1]]


I would like to put by own latitude and longitude in but alas when I use paste() to combine the double quotes become stuck as literally \"


lat <-10

long <20

library(httr)
sample2 <- GET(paste("https://elevation.mapzen.com/height?json={\"range\":false,\"shape\":[{\", lat , \":40.7,\", long,\":-76.5}]}&api_key=mycode"))
result2 <- content(sample2)
height <- result2$height[[1]]


Can you please suggest a way around this, it has been driving me mad!


Thank you so much.


Oliver

	[[alternative HTML version deleted]]



More information about the R-help mailing list