library(urlparse)
# Example 1: Modify the scheme and host of a URL
url_modify(
"https://user:pass@host.com/path?query#fragment",
scheme = "http",
host = "example.com"
)
# Example 2: Add a query parameter to a URL
url_modify(
"https://host.com/path", query = list(key1 = "value1", key2 = "value2")
)
# Example 3: Change the fragment of a URL
url_modify("https://host.com/path#old_fragment", fragment = "new_fragment")
Run the code above in your browser using DataLab