Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Encode a query string in R

Tags:

urlencode

r

Here is a query string that I use to plug into a form:

team,site,week,day,date,o:team,line,points,o:points@season=2011

and here is the resulting string that is passed to the website:

team%2Csite%2Cweek%2Cday%2Cdate%2Co%3Ateam%2Cline%2Cpoints%2Co%3Apoints%40season%3D2011

I know that R is a very powerful language. Are there any functions that would encode this for me? I figure I could write a function to mimic this output, but I didn't want to reinvent the wheel.

Any help will be greatly appreciated.

like image 470
Btibert3 Avatar asked Nov 06 '11 23:11

Btibert3


1 Answers

curlEscape in package RCurl does what you want:

> library(RCurl)
Loading required package: bitops
> curlEscape("team,site,week,day,date,o:team,line,points,o:points@season=2011")
[1] "team%2Csite%2Cweek%2Cday%2Cdate%2Co%3Ateam%2Cline%2Cpoints%2Co%3Apoints%40season%3D2011"
like image 190
themel Avatar answered Sep 30 '22 11:09

themel