---
title: ""
output: 
  html_document:
    toc: true
params:
  data: NA
  filename: NA
  fencoding: NA
  decimal: NA
  enc_guessed: NA
  vars1: NA
  continuity: NA
---

<style>
    pre {
        background-color: #FFFFFF !important;
        border: 0;
    }
</style>


```{r include=FALSE}
knitr::opts_chunk$set(comment = NA)
```

```{r, echo = FALSE}
# Style asis chunks
codechunk <- function(text, style=list(color="white")){
  cat(
    sprintf('<pre><code class="r" style="%s">%s</code></pre>', 
            do.call(function(...) sprintf(paste(c(names(style), ""), collapse = ":%s;"), ...), unname(style)), 
            code))
}
```

```{r child = 'report_kernel.Rmd', include = FALSE}
```

```{r include=FALSE}
if (exists("eval")) eval_code <- eval else eval_code <- FALSE
```

```{r, eval = FALSE, echo = eval_code}
# Import required libraries
import numpy as np
import pandas as pd
import seaborn as sns
import matplotlib.pyplot as plt 
from scipy import stats 
import math
import statsmodels.api as sm
from tabulate import tabulate
```


```{r, eval = FALSE, echo = eval_code}
# Set console printing options 
pd.set_option('display.max_rows', 500)
pd.set_option('display.max_columns', 20)
pd.set_option('display.width', 1000)
```


```{r, results="asis", eval = eval_code, echo = FALSE}
code1 <- "# Define the path to your data (remark the forward slash)
filepath = "
code <- paste0(code1, paste0("\"C:/",params$filename[1],"\""))
codechunk(code, style=list("background-color"="#FFFFFF"))
```

```{r, results="asis", eval = eval_code, echo = FALSE}
text1 <- "# Upload the data
df = "

if (params$decimal == "auto"){
  
  # First read with dot 
  datainput1 <- fread(params$filename$datapath, header = "auto", sep = "auto", dec=".", encoding = "unknown", data.table = FALSE, na.strings = "")
  
  # Define colnames to finally decide for decimal character  
  colnames <- sapply(datainput1, function(col) is.numeric(col) & Negate(is.integer)(col))
  
  if (sum(colnames) == 0L){
    
    # Probably comma as decimal
    text2 <- paste0("pd.read_csv(filepath, sep = None, decimal =\",\",  keep_default_na = False, na_values = \'\')")
    
  } else {
    
    # Probably dot as decimal 
     text2 <- paste0("pd.read_csv(filepath, sep = None, decimal =\".\",  keep_default_na = False, na_values = \'\')")
  }
  
} else {

  # User selection for decimal
  text2 <- paste0("pd.read_csv(filepath, sep = None, decimal = \"", params$decimal,"\",  keep_default_na = False, na_values = \'\')")
  
}

code <- paste0(text1,text2)
codechunk(code, style=list("background-color"="#FFFFFF"))
```

```{r child = 'report_code_common.Rmd', eval = eval_code}
```
