---
title: "&nbsp;"
output:
  pdf_document:
    toc: false
  html_document:
    theme: cosmo
    highlight: tango
---



```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```


```{r echo=FALSE, message=FALSE, warning=FALSE, results='asis'} 
suppressMessages(library(dplyr))
suppressMessages(library(knitr))
suppressMessages(library(kableExtra))

Plimits <- lapply(params$runPM, function(x) x@Caption) %>% unlist()
chk <- grepl("<", Plimits)
if (sum(chk)) {
  ind <- which(chk)  
  for (x in ind)
    Plimits[x] <- gsub("<", "\\\\<", Plimits[x])
}

if (length(Plimits)>1)
  cat("## Performance Objectives\n")
if (length(Plimits)==1)
  cat("## Performance Objective\n")

for (xx in 1:length(Plimits)) {
  # cat("#### ", xx, ": ", Plimits[xx], " \n\n", sep="")
  cat(xx, ": ", Plimits[xx], " \n\n", sep="")
}

```


```{r echo=FALSE, message=FALSE, warning=FALSE}
if (use.colors) {
  quants <- seq(0, 1, length.out=length(cols)-1)
  levels <- cut(quants, quants) %>% levels()
} else {
  # cols <- rep("black", length(quants)+1)
  show.legend <- FALSE
}
```

```{r echo=FALSE, message=FALSE, warning=FALSE}
htmlDF <- df # bind_rows(htmlDF1, htmlDF2)

TabDF <- tidyr::spread(htmlDF, PM, prob)
# if (format!='latex') TabDF <- cbind(data.frame("#"=1:nMPs), TabDF)

TabDF <- TabDF %>% dplyr::arrange(desc(min))

TabDF$min <- NULL
TabDF$prob <- NULL

MPwithurl <- !is.na(TabDF$url) 
TabDF$MP[MPwithurl] <- paste0("<a href='", TabDF$url[MPwithurl],"'>", TabDF$MP[MPwithurl],"</a>")
TabDF$url <- NULL
TabDF$Type <- as.factor(TabDF$Type)

cnames <- colnames(TabDF)
cind <- which(cnames == "Type")
cnames <- cnames[(cind+1):length(cnames)]



tabout <- DT::datatable(TabDF, escape=FALSE, filter='top', 
                        extensions = c('Buttons', 'Responsive'), 
                        class = 'cell-border stripe', 
                        options = list(
                          dom = 'Blfrtip',
                          buttons = 
                            list('copy', 'print'),
                          lengthMenu = list(c(10,20, 50, 100, -1), list('10', '20', '50','100', 'All')),
                          pageLength = 20, 
                          autoWidth = auto_width)) 
if (use.colors) tabout <- tabout %>% 
  DT::formatStyle(cnames, color = DT::styleInterval(cuts=quants, values=cols)) 

tabout


```