我有以下字符串:
url <- https://www.google.mu/webhp?sourceid=chrome-instant&ion=1&espv=2&ie=UTF-8#q=green carot
Run Code Online (Sandbox Code Playgroud)
我想用%20替换绿色和carot之间的空间
>url
https://www.google.mu/webhp?sourceid=chrome-instant&ion=1&espv=2&ie=UTF-8#q=green%20carot
Run Code Online (Sandbox Code Playgroud)
有一些功能可以使用url.在基地R使用URLencode
url <- "https://www.google.mu/webhp?sourceid=chrome-instant&ion=1&espv=2&ie=UTF-8#q=green carot"
URLencode(url)
#> [1] "https://www.google.mu/webhp?sourceid=chrome-instant&ion=1&espv=2&ie=UTF-8#q=green%20carot"
Run Code Online (Sandbox Code Playgroud)