server_files/loadData.R

K <- reactiveVal(1)
dataUnits <- reactiveVal()
bsList <- reactiveVal()
output$selectMsg <- renderPrint({
  if(is.null(input$dataFile)) {
    cat('Expected datafile format (.csv):\n\n')
    cat('"","Ref","Meth1","Meth2",...,"MethN"\n')
    cat('"Syst1","0.1","0.2","0.3",...,"0.4"\n')
    cat('...\n')
    cat('"SystM","0.5","0.6","0.7",...,"0.8"\n\n')
    return()
  }

  cat('Data set : ', input$dataFile[['name']],'\n\n')

  data = data.table::fread(
    file=input$dataFile$datapath,
    header=TRUE,
    data.table = FALSE)
  systems <<- data[,1]
  rownames(data) = systems
  Ref <<- data[,2]
  Data <<- data[,-c(1,2),]
  if(ncol(data) == 3) {
    # Single method in dataset: force df structure
    df = data.frame(data[,-c(1,2)])
    colnames(df) = colnames(data)[3]
    rownames(df) = systems
    Data <<- df
  }
  methList <<- colnames(Data)
  K(length(methList)) # Dynamic size for graphics updates
  if(input$useRelative)
    Errors   <<- (Ref - Data)/Ref
  else
    Errors   <<- Ref - Data

  dataUnits(input$units)
  if(input$useRelative)
    dataUnits('')

  cat('Systems  : ', length(systems),'\n')
  cat('Methods  : ', K(),'\n')
  cat('Units    : ', dataUnits(),'\n')
  cat('\n')
  cat('> Ref and Data (5 first lines):\n\n')
  M = data.table(cbind(Systems = systems, Ref = Ref, Data)[1:5,,drop=FALSE])
  print(M, trunc.cols = TRUE,row.names = FALSE)
  cat('\n')
  cat('> Errors (5 first lines):\n\n')
  M = data.table(cbind(Systems = systems, Errors)[1:5,,drop=FALSE])
  print(M, trunc.cols = TRUE,row.names = FALSE)
  cat('\n')


  # [Re]init misc global variables and reactive values
  bsList(NULL)
  lna = list(bs = NA, bs2 = NA)
  rankMat <<- list(mue = lna, q95hd = lna, msip = lna)

})

output$howTo <- renderText({
  '<h4>Short help on tabs:</h4>
  <ul style="list-style-type:none;">
    <li> <b>Data:</b> Choose a csv datafile and
                      decide if relative errors should be used.
    <li> <b>Outliers:</b> Detect and select global outliers using a
                     parallel plot. If outliers are selected, they are
                     removed from the dataset for further analyses.
    <li> <b>Statistics:</b> Compute summary statistics. Uncertainties
                     and some statistics are generated by bootstrap.
    <li> <b>HistDist:</b> Plot the distribution of errors as function
                     of calculated data, and errors histograms.
    <li> <b>QQ-Plot:</b> qq-plot the distribution of errors.
    <li> <b>PDFs:</b> Plot the Probability Density Functions of errors.
    <li> <b>ECDFs:</b> Plot the Empirical Cumulated Distribution
                    Functions of absolute errors.
    <li> <b>Lorenz:</b> Plot Lorenz curves, Gini and LAC statistics.
    <li> <b>Correlations:</b> Plot the correlation matrices of the
                    data, errors or statistics.
    <li> <b>Ranking:</b> Plot the Ranking Probability matrix.
    <li> <b>SIP mat.:</b> Plot the Systematic Improvement Probability matrix.
    <li> <b>Delta |Err|:</b> Pairwise stats - ECDF of the difference of
                      absolute errors and SIP, MG & ML.
    <li> <b>UQ:</b> Uncertainty Quantification (Experimental).

  </ul>'
})
ppernot/ErrView documentation built on Jan. 30, 2022, 6:59 a.m.