Learn R Programming

mstrio (version 11.2.0)

create_dataset: Create an in-memory MicroStrategy dataset (deprecated)

Description

Creates an in-memory dataset from an R Data.Frame. This function is deprecated. Check out the add_table() & create() method from the Dataset class, which allows for uploading multi-table datasets. Dataset

Usage

create_dataset(connection, data_frame, dataset_name, table_name,
  to_metric = NULL, to_attribute = NULL, folder_id = NULL,
  description = NULL)

# S4 method for connection create_dataset(connection, data_frame, dataset_name, table_name, to_metric = NULL, to_attribute = NULL, folder_id = NULL, description = NULL)

Arguments

connection

MicroStrategy REST API connection object

data_frame

R Data.Frame from which an in-memory dataset will be created

dataset_name

Name of the in-memory dataset

table_name

Name of the table to create within the dataset

to_metric

(optional) A vector of column names from the Data.Frame to format as metrics in the dataset. By default, numeric types are formatted as metrics while character and date types are formatted as attributes. For example, a column of integer-like strings ("1", "2", "3") would appear as an attribute in the newly created dataset. If the intent is to format this data as a metric, provide the corresponding column name as to_metric=c('myStringIntegers')

to_attribute

(optional) Logical opposite of to_metric. Helpful for formatting an integer-based row identifier as a primary key in the dataset

folder_id

(optional) ID of the shared folder that the dataset should be created within. If NULL, defaults to the user's My Reports folder.

description

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

Value

Unique identifiers of the dataset and table within the newly created dataset. Required for update_dataset()

Examples

Run this code
# NOT RUN {
df <- iris

# Create a primary key
df$ID <- as.character(row.names(df))

# Remove periods and other special characters due to their
# special role in MicroStrategy. But, "_" is ok.
names(df) <- c("Sepal_Length", "Sepal_Width", "Petal_Length", "Petal_Width", "Species", "ID")

# Create the dataset
mydf <- create_dataset(connection = conn,
                       data_frame = df,
                       dataset_name = "IRIS",
                       table_name = "IRIS")

# You can specify special treatment for columns within the data frame.
# This will convert the character-formatted row ID's to a MicroStrategy metric
mydf <- create_dataset(connection = conn,
                       data_frame = df,
                       dataset_name = "IRIS",
                       table_name = "IRIS",
                       to_metric = c("ID"))

# This will convert 'Sepal_Length' and 'Sepal_Width' to attributes
mydf <- create_dataset(connection = conn,
                       data_frame = df,
                       dataset_name = "IRIS",
                       table_name = "IRIS",
                       to_attribute = c("Sepal_Length", "Sepal_Width"))
# }

Run the code above in your browser using DataLab