Description Usage Arguments Details Value Examples
View source: R/url-manipulation.R
This function wraps add_parameter
, allowing for multiple
parameters to be suffixes to a URL at once, and for parameters and their
values to be provided as named arguments. Parameters are suffixed to a URL,
like so: "request?para1=value1¶2=value2". The first parameter is suffixed
with "?" and all others after that "&". This function will determine the
correct suffix based on the presence of "&" in the request. If a given
parameter value is NULL
or of length 0 then it will not be appended to the
URL.
1 | add_parameters(request, ..., .combine = "repeat_name")
|
request |
Character. The base URL or request which will be suffixed with the parameter. |
... |
The parameters to be suffixed, with name/value pairs provided as arguments. |
.combine |
How to combine parameters with multiple values. One of "repeat_name", "with_commas", "with_hex_commas". Alternatively, a custom character can be provided here which will be used to separate the values. See Details. |
There is no standardised way to combine multiple values for a parameter. You should see how your API expects multiple values to be provided to the same parameter. This function allows for the following strategies. If any other value is provided, then the values will be concatenated and separated with the provided value.
"repeat_name" (default). The values of the parameter are repeated
with the parameter name. For example, ("request", "para", c(1, 2))
will
return "request?para=1¶=2".
"with_commas". The values of the parameter are concatenated and
separated with commas. For example, ("request", "para", c(1, 2))
will
return "request?para=1,2".
"with_commas". The values of the parameter are concatenated and
separated with the ASCII keycode in hexadecimal for a comma ("%2C"). For
example, ("request", "para", c(1, 2))
will return "request?para=1%2C2".
Character. The request with suffixed parameters.
1 2 3 4 5 6 7 8 9 10 11 12 | add_parameters("www.example.com", animal = "crocodile")
add_parameters(
"www.example.com",
animal = "crocodile",
food = "cherries"
)
add_parameters(
"www.example.com",
animal = "crocodile",
numbers = c(1, 2, 3),
.combine = "repeat_names"
)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.