# R

## R Usage Guide

Select a card below to access R-specific usage information.&#x20;

<table data-view="cards"><thead><tr><th></th><th align="center"></th><th></th><th data-hidden data-card-cover data-type="files"></th><th data-hidden data-card-target data-type="content-ref"></th></tr></thead><tbody><tr><td></td><td align="center"><strong>Installation</strong></td><td></td><td><a href="https://650896658-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F3Or28XkZfNq0bJ4X4zXE%2Fuploads%2FF8CAbXuzhrPwGWa6zlNa%2Finstall_light.png?alt=media&#x26;token=21688f0b-0bf0-4c23-ba51-8dd963610bed">install_light.png</a></td><td><a href="#installation">#installation</a></td></tr><tr><td></td><td align="center"><strong>Getting started</strong></td><td></td><td><a href="https://650896658-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F3Or28XkZfNq0bJ4X4zXE%2Fuploads%2Fr1diq559YdaJUQC59HPq%2Fgetting_started_light.png?alt=media&#x26;token=1610ab74-4c4a-4913-be0b-c94b82789040">getting_started_light.png</a></td><td><a href="#getting-started-basic-usage">#getting-started-basic-usage</a></td></tr><tr><td></td><td align="center"><strong>Advanced usage</strong></td><td></td><td><a href="https://650896658-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F3Or28XkZfNq0bJ4X4zXE%2Fuploads%2FVp77e7uxRSGSKofCzCsi%2Fadv_usage_light.png?alt=media&#x26;token=e9d847f8-c0e0-4c6a-8978-cf8cae909335">adv_usage_light.png</a></td><td><a href="#advanced-usage">#advanced-usage</a></td></tr><tr><td></td><td align="center"><strong>Frequently Asked Questions</strong></td><td></td><td><a href="https://650896658-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F3Or28XkZfNq0bJ4X4zXE%2Fuploads%2FVoIelJ6Az7SxLzLNK6qV%2FFAQ_light.png?alt=media&#x26;token=4f1069ed-e997-43db-818b-1b4f7e271f14">FAQ_light.png</a></td><td><a href="#faq">#faq</a></td></tr><tr><td></td><td align="center"><strong>API Reference</strong></td><td></td><td><a href="https://650896658-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F3Or28XkZfNq0bJ4X4zXE%2Fuploads%2FZTxH8hTf6cI38O4HxE3Q%2FAPI_light.png?alt=media&#x26;token=82a277cc-a7a3-404a-a6f8-5a0c68361ecc">API_light.png</a></td><td><a href="../information-about-catch22/api-reference/r-api">r-api</a></td></tr></tbody></table>

***

***

## Installation

***

You can install the stable version of *Rcatch22* from [CRAN](https://cran.r-project.org/web/packages/Rcatch22/readme/README.html) using the following:

```r
install.packages("Rcatch22")
```

***

## Getting Started: Basic Usage

Here we outline how you can jump straight into computing *catch22* features on your time series data with a basic usage example.

### Expected Input

*Rcatch22* expects a **single univariate time series** as a **numeric** vector with length equal to the number of points in the time series. For example, consider a time series with length 100:

```r
library(Rcatch22)
data <- stats::rnorm(100) # your time series data
```

### Computing *catch22* features

To compute *catch22* features, call the `catch22_all` function on your time series data as follows:

```r
outs22 <- catch22_all(data)
```

### Expected output

A data frame is returned with two columns: `names` and `features` as shown below

```
outs22
##                                          names       values
## 1                           DN_HistogramMode_5  0.432653377
## 2                          DN_HistogramMode_10  0.174395817
## 3                                    CO_f1ecac  1.865299453
...                                ...                 ...
## 21            SP_Summaries_welch_rect_centroid  1.178097245
## 22                 FC_LocalSimple_mean3_stderr  1.201213638
```

To access the full list of feature names, you can also run `feature_list.`

And that's it! You now have all the knowledge you need to apply *catch22* to your time series data. To access some of the additional functionality of *catch22*, keep reading for advanced usage tips and examples.

***

***

## Advanced Usage

Ready to explore some of the additional functionality of *Rcatch22?*&#x20;

### 1. *Catch24*

If the location and spread of the raw time series distribution may be important for your application, you can enable *catch24.*

{% tabs %}
{% tab title="Catch24" %}
*Catch24* is an extension of the original *catch22* feature set to include **mean** and **standard deviation,** yielding a total of **24** time series features. An option to include the mean and standard deviation as features in addition to *catch22* is available through setting the *catch24* argument to `TRUE`:

```r
library(Rcatch22)

x <- 1 + 0.5 * 1:1000 + arima.sim(list(ma = 0.5), n = 1000)
features <- catch22_all(x, catch24 = TRUE)
```

{% endtab %}
{% endtabs %}

### 2. Computing Individual Features

If you do not wish to compute the full *catch22* feature set on your time series, you can alternatively compute each feature (including mean and std. deviation) individually.

{% tabs %}
{% tab title="Computing Individual Features" %}
In *pycatch22* each feature function can be accessed individually and takes **arrays** as **tuples** or To compute individual features in *Rcatch22*, you can access the feature functions using their unique names (as shown in the [feature overview table](https://time-series-features.gitbook.io/catch22/information-about-catch22/feature-descriptions/feature-overview-table)). Note that feature functions are given by the feature long name e.g.,`IN_AutoMutualInfoStats_40_gaussian_fmmi`.

For example, let's compute the feature `IN_AutoMutualInfoStats_40_gaussian_fmmi` on a single univariate time series:

```r
library(Rcatch22)
x <- 1 + 0.5 * 1:1000 + arima.sim(list(ma = 0.5), n = 1000)
f <- IN_AutoMutualInfoStats_40_gaussian_fmmi(x)
```

{% endtab %}
{% endtabs %}

***

## FAQ

***

Click one of the expandable tabs below to explore commonly asked questions about *Rcatch22*:

<details>

<summary>How does computational time scale as a function of time series length in Rcatch22?</summary>

With features coded in C, *Rcatch22* is highly computationally efficient, scaling nearly linearly with time series size. Computation time in seconds for a range of time series lengths is presented [here](https://github.com/hendersontrent/Rcatch22?tab=readme-ov-file#computational-performance).&#x20;

</details>

<details>

<summary>How can I submit a bug report for <em>Rcatch22?</em> </summary>

If you would like to submit a bug report, you can access our Bug Tracker [here](https://github.com/hendersontrent/Rcatch22/issues). For guidelines on submitting an ideal bug report, see our page on [contributing to *catch22*](https://time-series-features.gitbook.io/catch22/information-about-catch22/contributing-to-catch22)*.*&#x20;

</details>

***
