URL | R Documentation |
URL class.
URL class.
This class represents a URL object that can be used in requests. It handles parameters as a list, making it easy to build URLs for contacting web services.
new()
Initializer.
URL$new(url = character(), params = character(), chomp_extra_slashes = TRUE)
url
The URL to access, as a character vector.
params
The list of parameters to append to this URL. If it is an
unnamed list or vector, the values will be converted to strings and
concatenated with the &
separator. If it is a named list or vector, the
names will be used as keys as in "name1=value1&name2=value2&...".
chomp_extra_slashes
If set to TRUE, then slashes at the end and the beginning of each element of the url vector parameter will be removed before proper concatenation.
Nothing.
# Create a URL object url <- sched::URL$new("https://www.my.server/", c(param1=12, param2='abc'))
getDomain()
Etracts the domain name from the URL.
URL$getDomain()
The domain.
# Create a URL object url <- sched::URL$new("https://www.my.server/", c(param1=12, param2='abc')) # Extract the domain name print(url$getDomain())
setUrl()
Sets the base URL string.
URL$setUrl(url)
url
The base URL string.
Nothing.
# Create an empty URL object url <- sched::URL$new() # Set the URL url$setUrl('https://www.my.server/') # Convert the URL to a string print(url$toString())
setParam()
Sets a parameter.
URL$setParam(key, value)
key
The parameter name.
value
The value of the parameter.
Nothing.
# Create an URL object url <- sched::URL$new('https://www.my.server/') # Set a parameter url$setParam('a', 12) # Convert the URL to a string print(url$toString())
print()
Displays information about this instance.
URL$print()
self as invisible.
# Create an URL object url <- sched::URL$new('https://www.my.server/') # Print the URL object print(url)
toString()
Gets the URL as a string representation.
URL$toString(encode = TRUE)
encode
If set to TRUE, then encodes the URL.
The URL as a string, with all parameters and values set.
# Create an URL object url <- sched::URL$new('https://www.my.server/', c(a=12)) # Convert the URL to a string print(url$toString())
clone()
The objects of this class are cloneable with this method.
URL$clone(deep = FALSE)
deep
Whether to make a deep clone.
# Create a URL object from a base URL string and a list of parameters
base.url <- c("https://www.uniprot.org", "uniprot")
params <- c(query="reviewed:yes+AND+organism:9606",
columns='id,entry name,protein names',
format="tab")
url <- sched::URL$new(url=base.url, params=params)
# Print the URL converted to a string
print(url$toString())
## ------------------------------------------------
## Method `URL$new`
## ------------------------------------------------
# Create a URL object
url <- sched::URL$new("https://www.my.server/", c(param1=12,
param2='abc'))
## ------------------------------------------------
## Method `URL$getDomain`
## ------------------------------------------------
# Create a URL object
url <- sched::URL$new("https://www.my.server/",
c(param1=12, param2='abc'))
# Extract the domain name
print(url$getDomain())
## ------------------------------------------------
## Method `URL$setUrl`
## ------------------------------------------------
# Create an empty URL object
url <- sched::URL$new()
# Set the URL
url$setUrl('https://www.my.server/')
# Convert the URL to a string
print(url$toString())
## ------------------------------------------------
## Method `URL$setParam`
## ------------------------------------------------
# Create an URL object
url <- sched::URL$new('https://www.my.server/')
# Set a parameter
url$setParam('a', 12)
# Convert the URL to a string
print(url$toString())
## ------------------------------------------------
## Method `URL$print`
## ------------------------------------------------
# Create an URL object
url <- sched::URL$new('https://www.my.server/')
# Print the URL object
print(url)
## ------------------------------------------------
## Method `URL$toString`
## ------------------------------------------------
# Create an URL object
url <- sched::URL$new('https://www.my.server/', c(a=12))
# Convert the URL to a string
print(url$toString())
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.