---
title: "Using DescriptiveStats.OBeu with OpenCPU"
author: "Kleanthis Koupidis, Aikaterini Chatzopoulou, Charalampos Bratsas"
output: rmarkdown::html_vignette
vignette: >
  %\VignetteIndexEntry{Using DescriptiveStats.OBeu with OpenCPU}
  %\VignetteEngine{knitr::rmarkdown}
  %\VignetteEncoding{UTF-8}
---

# Introduction

This document describes the use of the functions implemented in *DescriptiveStats.OBeu* package in *OpenCPU* environment, after *[installing OpenCPU](https://www.opencpu.org/download.html)* and *DescriptiveStats.OBeu* package on OpenCPU server address(/ocpu/test).

# How to use functions

- Go to: yourserver/ocpu/test

- Type to the endpoint:

```{r, eval=FALSE, include=TRUE}
 ../library/ {name of the library} /R/ {function}
```

- If you want to see the function parameters you should: 

    - Select Method: **`Get`**
    
- To run a function you should:

    - Select Method: **`Post`**

- Then you can click on **Ajax Request**.

# OpenCPU and DescriptiveStats.OBeu

## ds.analysis
In this example we will use `ds.analysis` function that returns in a single call a json string or a list with the following components:

+---------------+------------------------+-----------------------------------------------------------+
| Component     | Output                 | Description                                               |
+===============+========================+===========================================================+
| `statistics`  | - Min                  | - The minimum observed value of the input data            |
|               | - Max                  | - The maximum observed value of the input data            |
|               | - Range                | - The difference between maximum and minimum              |
|               | - Mean                 | - The average value of the input data                     |
|               | - Median               | - The median value of the input data                      |
|               | - Quantiles            | - The 25%, 75% percentiles                                |
|               | - Variance             | - The variance of the input data                          |
|               | - StandardDeviation    | - The standard deviation of the input data                |
|               | - Skewness             | - The Skewness of the input data                          |
|               | - Kurtosis             | - The Kurtosis of the input data                          |
+---------------+------------------------+-----------------------------------------------------------+
| `boxplot`     | - lo.whisker           | - Lower horizontal line out of the box                    |
|               | - lo.hinge             | - Lower horizontal line of the box                        |
|               | - median               | - Horizontal line in the box                              |
|               | - up.hinge             | - Upper horizontal line of the box                        |
|               | - up.whisker           | - Upper horizontal line out of the box                    |
|               | - box.width            | - The box width of each variable                          |
|               | - lo.out               | - Lower outliers                                          |
|               | - up.out               | - Upper outliers                                          |
|               | - n                    | - The number of non-NA observations                       |
+---------------+------------------------+-----------------------------------------------------------+
| `histogram`   | - cuts                 | - The boundaries of the histogram classes                 |
|               | - counts               | - The frequency of each histogram class                   |
|               | - mean                 | - The average value of the input vector                   |
|               | - median               | - The median value of the input data                      |
+---------------+------------------------+-----------------------------------------------------------+
| `frequencies` | - Variable name        | - The name of the calculated variable                     |
|               | - frequencies          | - The frequency value                                     |
|               | - "_row"               | - Name of the categories of the variable                  |
|               | - relative.frequencies | - Relative frequency values                               |
+---------------+------------------------+-----------------------------------------------------------+
| `correlation` | - Variable name        | - The name of the calculated variable                     |
|               | - Correlation value    | - The correlation value                                   |
|               | - "_row"               | - The corresponding correlation variable                  |
+---------------+------------------------+-----------------------------------------------------------+

Table: *`ds.analysis`* components

## Select library and function

1. Go to: yourserver/ocpu/test

2. Copy and paste the following function to the endpoint 
```{r, eval=FALSE, include=TRUE}
../library/DescriptiveStats.OBeu/R/ds.analysis
# library/ {name of the library} /R/ {function}
```

3. **Select Method**: **`Post`**

## Adding parameters parameters

Click **add parameters** every time you want to add a new parameters and values.

4. Define the input data:

    - **Param Name**: **`data`**
    - **Param Value**: **`Wuppertal_df`** 

5. Define the *outliers* parameter(optional):

    - **Param Name**: **`outliers`**
    - **Param Value**: **`FALSE`**


6. Define the *fr.select* parameter(optional):

    - **Param Name**: **`fr.select`**
    - **Param Value**: **`"Produktbereich"`**


You add likewise further parameters and change the default parameters of `c.out`, `box.width`, `hist.class`, `corr.method`, see DesciptiveStats.OBeu *reference manual* for further details.


7. Ready! Click on **Ajax request**!

## Results

8. copy the **/ocpu/tmp/{this_id_number}/R/.val** (second on the right panel)

9. finally, paste **`yourserver/ocpu/tmp/{this_id_number}/R/.val`** on a new tab.


# Further Details

+ [HTTP in OpenCPU](https://www.opencpu.org/api.html)
+ [OpenCPU Help](https://www.opencpu.org/help.html)
+ [OpenCPU JavaScript Client](https://www.opencpu.org/jslib.html)
+ [OpenCPU on CRAN](https://cran.r-project.org/package=opencpu)

# Github
+ [OpenCPU package *development version*](https://github.com/opencpu/opencpu)
+ [DescriptiveStats.OBeu package *development version*](https://github.com/okgreece/DescriptiveStats.OBeu)
