Row

Plot

Row

Table

---
title: "Pharmacokinetics Prediction: Nonlinear Response Function Model"
output: 
  flexdashboard::flex_dashboard:
    orientation: rows
    theme: lumen
    source_code: embed
---

```{r setup, include=FALSE}
library(flexdashboard)
library(crosstalk)
library(dplyr)
library(plotly)
library(DT)
library(ggplot2)

setwd("~/pmd/nldpTest")

results <- read.csv(file = 'results.csv')

my_colnames <- colnames(results)

propspacesets <- read.csv(file = 'propspacesets.csv')

sd <- SharedData$new(results)
```

Inputs {.sidebar}
-----------------------------------------------------------------------

```{r}

filter_slider("sl1", my_colnames[3], sd, my_colnames[3], round = TRUE)
filter_checkbox("grpid", "Prop Set", sd, ~GRPID, inline = FALSE)
```

Row {data-height=600}
-------------------------------------
    
### Plot

```{r}

fig <- plot_ly(sd, x = ~Time, y = ~Data, color = ~GRPID, type = 'scatter', mode = 'markers', name = ~LINEID, text = ~paste('Type: ', Type))
  fig <- fig %>% add_trace(y = ~Fit, color = ~GRPID, type = 'scatter', mode = 'lines', name = ~LINEID, line = list(shape="spline"), text = ~paste('Type: Fit'))
  fig <- fig %>% add_trace(y = ~Pred, color = ~GRPID, type = 'scatter', mode = 'lines', name = ~LINEID, line = list(shape = "spline", dash = "dash"), text = ~paste('Type: Pred'))
  fig <- fig %>% layout(xaxis = list(title = paste(my_colnames[5])), yaxis = list(title = paste(my_colnames[9])))

fig
```

Row {data-height=400}
-------------------------------------
    
### Table

```{r}
library(DT)

datatable(propspacesets, extensions="Scroller", style="bootstrap", class="compact",
          width="100%", rownames=NULL,
          options=list(
            deferRender=TRUE, scrollY=300, scroller=FALSE, paging=FALSE,
            columnDefs = list(list(className = 'dt-right', targets=c(0)))
          )
        )
```