# 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)
# This would contain the loading code that will cascade down
# to the other modules when generating snippets and
# reproducible scripts
code = ds_read_res$code
# This is the R Object name that is used internally
# and in generated scripts. Should be the same as in
# the code above
object_name = ds_read_res$object_name
# This is the actual dataset:
contents = ds_read_res$contents
state = UD_attach_ds(
state,
data_file_local = data_file_local,
data_file_ext = ".xlsx",
data_file = data_file,
sheet = sheet,
sheets = sheets,
code = code,
object_name = object_name,
contents = contents)
state
Run the code above in your browser using DataLab