Learn R Programming

mstrio (version 11.2.1)

Dataset: Create, update, delete and certify MicroStrategy datasets

Description

When creating a new dataset, provide a dataset name and an optional description. When updating a pre-existing dataset, provide the dataset identifier. Tables are added to the dataset in an iterative manner using `add_table()`.

Arguments

Public fields

connection

MicroStrategy connection object

name

Name of the dataset

description

Description of the dataset. Must be less than or equal to 250 characters

dataset_id

Identifier of a pre-existing dataset. Used when updating a pre-existing dataset

verbose

Print API requests to console. Used for debugging

Active bindings

connection

MicroStrategy connection object

Methods

Public methods

Method new()

Usage

Dataset$new(
  connection,
  name = NULL,
  description = NULL,
  dataset_id = NULL,
  verbose = FALSE
)

Method add_table()

Usage

Dataset$add_table(
  name,
  data_frame,
  update_policy,
  to_metric = NULL,
  to_attribute = NULL
)

Method create()

Usage

Dataset$create(folder_id = NULL, auto_upload = TRUE)

Method update()

Usage

Dataset$update(chunksize = 1e+05)

Method publish()

Usage

Dataset$publish()

Method publish_status()

Usage

Dataset$publish_status()

Method delete()

Usage

Dataset$delete()

Method certify()

Usage

Dataset$certify()

Method clone()

The objects of this class are cloneable with this method.

Usage

Dataset$clone(deep = FALSE)

Arguments

deep

Whether to make a deep clone.

Examples

Run this code
# NOT RUN {
# Create data frames
df1 <- data.frame("id" = c(1, 2, 3, 4, 5),
                  "first_name" = c("Jason", "Molly", "Tina", "Jake", "Amy"),
                  "last_name" = c("Miller", "Jacobson", "Turner", "Milner", "Cooze"))

df2 <- data.frame("id" = c(1, 2, 3, 4, 5),
                  "age" = c(42, 52, 36, 24, 73),
                  "state" = c("VA", "NC", "WY", "CA", "CA"),
                  "salary" = c(50000, 100000, 75000, 85000, 250000))

# Create a list of tables containing one or more tables and their names
my_dataset <- Dataset$new(connection=conn, name="HR Analysis")
my_dataset$add_table("Employees", df1, "add")
my_dataset$add_table("Salaries", df2, "add")
my_dataset$create()

# By default Dataset$create() will upload the data to the Intelligence Server and publish the
 dataset.
# If you just want to create the dataset but not upload the row-level data, use
Dataset$create(auto_upload=FALSE)

# followed by
Dataset$update()
Dataset$publish()

# When the source data changes and users need the latest data for analysis and reporting in
# MicroStrategy, mstrio allows you to update the previously created dataset.

ds <- Dataset$new(connection=conn, dataset_id="...")
ds$add_table(name = "Stores", data_frame = stores_df, update_policy = 'update')
ds$add_table(name = "Sales", data_frame = stores_df, update_policy = 'upsert')
ds$update()
ds$publish()

# By default, the raw data is transmitted to the server in increments of 25,000 rows. On very
# large datasets (>1 GB), it is beneficial to increase the number of rows transmitted to the
# Intelligence Server with each request. Do this with the chunksize parameter:

ds$update(chunksize = 500000)

# If you want to cerfify an existing dataset, use
ds$certify()
# }

Run the code above in your browser using DataLab