param_set

0th

Percentile

Set the value associated with a parameter in a URL's query.

URLs often have queries associated with them, particularly URLs for APIs, that look like ?key=value&key=value&key=value. param_set allows you to modify key/value pairs within query strings, or even add new ones if they don't exist within the URL.

Usage
param_set(urls, key, value)
Arguments
urls
a vector of URLs. These should be decoded (with url_decode) but do not have to have been otherwise manipulated.
key
a string representing the key to modify the value of (or insert wholesale if it doesn't exist within the URL).
value
a value to associate with the key. This can be a single string, or a vector the same length as urls
Value

the original vector of URLs, but with modified/inserted key-value pairs.

See Also

param_get to retrieve the values associated with multiple keys in a vector of URLs, and param_remove to strip key/value pairs from a URL entirely.

Aliases
  • param_set
Examples
# Set a URL parameter where there's already a key for that
param_set("https://en.wikipedia.org/api.php?action=query", "action", "pageinfo")

# Set a URL parameter where there isn't.
param_set("https://en.wikipedia.org/api.php?list=props", "action", "pageinfo")

Documentation reproduced from package urltools, version 1.4.0, License: MIT + file LICENSE

Community examples

Looks like there are no examples yet.