DomoR Usage
Intro
This topic lists and describes a number of DomoR commands available from the R command line.
Video - Domo R Plugin Overview
Help
To open the embedded help file, enter the following command:
help(package=DomoR)
List
To open a list of all your DataSets, enter the following command:
DomoR::list_ds()
The returned list will look something like the following:
Index |
ID |
dataProviderType |
Name |
---|---|---|---|
1 |
a02f0cdf-d1a4-4d75-9729-8135e499a8d9 |
|
User Profile Metrics |
2 |
87703789-3778-4882-ad9a-00514fd55e5b |
|
Recent Media Likes |
3 |
014cfa9c-7aa3-4b24-acaf-f90c768542d9 |
google-analytics |
Campaign Metrics |
4 |
48d49aa4-6e03-451a-906b-2aa6610dbd55 |
Mysql |
Customers |
The ID can be used to explicitly fetch a data source. For convenience, the Index number can also be used to reference a data source. Be careful using the Index number, as it always fetches the data source from the most recent listing. For more information, see the next section.
You can also provide various arguments to narrow the results. For more examples, use this command to access the DomoR documentation:
?list_ds()
Fetch
Fetch a data source using the Index number from the list obtained using list_ds().
df <- DomoR::fetch(1)
Or specify an ID directly.
df <- DomoR::fetch('48d49aa4-6e03-451a-906b-2aa6610dbd55')
Make sure to assign the fetched data source to a data frame variable so you can manipulate the data. If you don't specify a variable to assign it to, the data source is output to the console.
Create
Create a data source by passing in a data frame with a name and description, where df is your data frame variable from which you'll create a data source in Domo.
DomoR::create(df, name=" Dataset Name", description="Dataset Description")
Replace
Replace an existing data source and update the schema if necessary. This command is available only for DataSets that were created using the R plugin or Domo Streams API.
DomoR::replace_ds('ab84f24a-73d4-0188-d8aa-8fe78103a721', df)
A warning will appear on the console if the schema is changed.
For additional details use this command to access the DomoR documentation:
?replace_ds()
Setting data types
Domo looks at the first 1000 rows to determine data types, if there are no values in the first 1000 rows, it will set the default data type as col_logical()
Example:
DomoExample <- DomoR::fetch('6266255d-b0f4-4e43-9982-254ea4104596', col_types=readr::cols(employee_contribution_percent=readr::col_double(), employee_contribution_amt=readr::col_double()))
To verify the data types:
DomoExample %>% as_tibble()