This function sends a request to the PubChem PUG REST API to retrieve various types of data for a given identifier. It supports fetching data in different formats and allows saving the output.
get_pug_rest(
identifier = NULL,
namespace = "cid",
domain = "compound",
operation = NULL,
output = "JSON",
searchtype = NULL,
property = NULL,
options = NULL,
save = FALSE,
dpi = 300,
path = NULL,
file_name = NULL,
...
)
Depending on the output format, this function returns different types of content: JSON or JSONP format returns parsed JSON content. CSV format returns a data frame. TXT format returns a table. SDF returns SDF file of requested identifier. PNG format returns an image object or saves an image file.
A vector of identifier for the query, either numeric or character.
A character string specifying the namespace for the request. Default is 'cid'.
A character string specifying the domain for the request. Default is 'compound'.
An optional character string specifying the operation for the request.
A character string specifying the output format. Possible values are 'SDF', 'JSON', 'JSONP', 'CSV', 'TXT', and 'PNG'. Default is 'JSON'.
An optional character string specifying the search type.
An optional character string specifying the property for the request.
A list of additional options for the request.
A logical value indicating whether to save the output as a file or image. Default is FALSE.
An integer specifying the DPI for image output. Default is 300.
description
a character of length 1. Define the name of file (without file extension) to save. If NULL, default file name is set as "files_downloaded".
description
result <- get_pug_rest(identifier = "2244", namespace = "cid", domain = "compound", output = "JSON")
Run the code above in your browser using DataLab