Decoding URL character string vector in R
decode, r, url
Solution
You can apply a function to a vector with `sapply`. It will return the result vector:
> urlencoded <- c("im%20looking%20for%20uncle", "im%20looking%20for%20sister")
> sapply(urlencoded, URLdecode, USE.NAMES = FALSE)
[1] "im looking for uncle" "im looking for sister"
Problem
Suppose you have an atomic vector containing URL encoded character strings. For example: ``` urlencoded<-c("im%20looking%20for%20uncle","im%20looking%20for%20sister") ``` Is there any way to decode every element in the vector, returning a vector of the same length with regular text? In other words, the output should be: ``` c("im looking for uncle","im looking for sister") ``` URLdecode in base R doesn't vectorize and it's slow. There are lots of utilities outside of R that quickly decode URL encoded character strings, but I can't find any good utility in R.