UD_ds_read {formods}R Documentation

Generate Code and Load DS

Description

Generates the code for loading a dataset and returns both the code and the contents

Usage

UD_ds_read(
  state,
  data_file_ext = NULL,
  data_file_local = NULL,
  data_file = NULL,
  sheets = NULL,
  sheet = NULL
)

Arguments

state

UD state from UD_fetch_state()

data_file_ext

File extension of the uploaded file (e.g. "xlsx", "csv", etc).

data_file_local

Full path to the data file on the server.

data_file

Dataset file name without the path.

sheets

If the uploaded file is an excel file, this is a character vector of the sheets present in that file.

sheet

If the uploaded file is an excel file, this is the currently selected sheet.

Value

list with the elements of the dataset (contents, object_name, code, and isgood)

Examples

# We need a module state object to use this function:
id="UD"
sess_res = UD_test_mksession(session=list())
state = sess_res$state

# This is the full path to a test data file:
data_file_local  =  system.file(package="formods", "test_data", "TEST_DATA.xlsx")

# Excel file extension
data_file_ext    = "xlsx"

# Base file name
data_file        = "TEST_DATA.xlsx"

# Excel files need a sheet specification:
sheet            = "DATA"

# We will also attach the sheets along with it
sheets = readxl::excel_sheets(data_file_local)

ds_read_res = UD_ds_read(state,
  data_file_ext   = data_file_ext,
  data_file_local = data_file_local,
  data_file       = data_file,
  sheets          = sheets,
  sheet          = sheet)

ds_read_res

[Package formods version 0.1.6 Index]