---
title: "FreesearchR"
output: rmarkdown::html_vignette
vignette: >
  %\VignetteIndexEntry{FreesearchR}
  %\VignetteEngine{knitr::rmarkdown}
  %\VignetteEncoding{UTF-8}
---

```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE,eval = FALSE)
source(here::here("functions.R"))
```

# Getting started with ***FreesearchR***

Below is a simple walk-trough and basic instructions for the functions on the FreesearchR app.

## Launching

The easiest way to get started is to launch [the hosted version of the app on shinyapps.io (click this link)](https://agdamsbo.shinyapps.io/freesearcheR/).

Additionally you have the option to run the app locally with access to any data in your current working environment.

To do this, open *R* (or RStudio or similar), and run the following code to install the latest version of ***FreesearchR*** and launch the app:

```{r}
require("pak")
pak::pak("agdamsbo/FreesearchR")
library(FreesearchR)
FreesearchR::launch_FreesearchR()
```

As a small note, a standalone Windows app version is on the drawing board as well, but no time frame is available.

## Importing data

Once in the app and in the "*Import*", you have three options available for importing data: file upload, REDCap server export and local or sample data.

After choosing a data source, you can set a threshold to filter data be completenes and further manually specify variables to include for analyses.

### File upload

Currently several data file formats are supported for easy import (csv, txt, xls(x), ods, rds, dta). If importing workbooks (xls(x) or ods), you are prompted to specify sheet(s) to import. If choosing multiple sheets, these are automatically merged by common variable(s), so please make sure that key variables are correctly named identically.

### REDCap server export


### Local or sample data


## Evaluate

### Baseline

### Correlation matrix


## Visualise

Below are the available plot types listed.

```{r echo = FALSE, eval = TRUE}
c("continuous", "dichotomous", "ordinal", "categorical") |> 
  lapply(\(.x){
    dplyr::bind_cols(
      dplyr::tibble("Data type"=.x),
      supported_plots() |> 
      lapply(\(.y){
        if (.x %in% .y$primary.type){
          .y[c("descr","note")]|> dplyr::bind_cols()
        }
})|> 
  dplyr::bind_rows() |> 
  setNames(c("Plot type","Description")))
  }) |> 
  dplyr::bind_rows() |> 
  toastui::datagrid(filters=TRUE,theme="striped")
```


## Regression


## Download

### Report


### Data


### Code
