Skip to contents

Takes a data frame and information in the site configureation to produce formatting information to make it easier for the user to see data type information.

Usage

FM_fetch_data_format(df, state)

Arguments

df

Raw dataframe to be built into an rhandsontable.

state

Current module state after yaml file has been read.

Value

list with the following elements:

  • col_heads: List (element for each column) of formatting information for column headers to be use with rhandsontable.

  • col_subtext: List (element for each column) of subtext to be displayed in selections using `pickerInput` from the `shinyWidgets` package.

Examples

# We need a module state object to use this function:
sess_res = UD_test_mksession(session=list())
#> → UD: including file
#> → UD:   source: file.path(system.file(package="onbrand"), "templates", "report.docx")
#> → UD:   dest:   file.path("config","report.docx")
#> → UD: including file
#> → UD:   source: file.path(system.file(package="onbrand"), "templates", "report.pptx")
#> → UD:   dest:   file.path("config","report.pptx")
#> → UD: including file
#> → UD:   source: file.path(system.file(package="onbrand"), "templates", "report.yaml")
#> → UD:   dest:   file.path("config","report.yaml")
#> → UD: State initialized
#> → UD: module checksum updated:897d952fecbc804999396a96f9df4b20
state = sess_res$state

data_file_local =  system.file(package="formods", "test_data", "TEST_DATA.xlsx")
sheet           = "DATA"

df = readxl::read_excel(path=data_file_local, sheet=sheet)

hfmt = FM_fetch_data_format(df, state)

# Column header formatting
head(as.vector(unlist( hfmt[["col_heads"]])))
#> [1] "<span style='color:#3C8DBC'><b>ID</b><br/><font size='-3'>num</font></span>"      
#> [2] "<span style='color:#3C8DBC'><b>TIME_DY</b><br/><font size='-3'>num</font></span>" 
#> [3] "<span style='color:#3C8DBC'><b>TIME_HR</b><br/><font size='-3'>num</font></span>" 
#> [4] "<span style='color:#3C8DBC'><b>NTIME_DY</b><br/><font size='-3'>num</font></span>"
#> [5] "<span style='color:#3C8DBC'><b>NTIME_HR</b><br/><font size='-3'>num</font></span>"
#> [6] "<span style='color:#3C8DBC'><b>TIME</b><br/><font size='-3'>num</font></span>"    

# Column select subtext
head(as.vector(unlist( hfmt[["col_subtext"]])))
#> [1] "num: 1,⋅⋅⋅,360"  "num: 0,⋅⋅⋅,84"   "num: 0,⋅⋅⋅,2016" "num: 0,⋅⋅⋅,42"  
#> [5] "num: 0,⋅⋅⋅,1008" "num: 0,⋅⋅⋅,2016"