## Introduction

This article outlines the various methods of accessing and using R in Displayr.

## Requirements

- A Displayr document.

## Method

There are a number of ways to use R from within Displayr:

- Entering R code directly into a
**Calculation**. - Creating an
**R Variable**. - Creating a new
**Data Set**using R*.* - Accessing pre-written R code using menus and forms. This is how most advanced analyses are conducted in Displayr (e.g., regression, principal components analysis). This is referred to as
**Standard R**. - Automatic updating. Any R code that is created via
*Calculations*,*Standard R*, or*QScripts*is set to automatically update when the inputs change (e.g., if the input data changes, if a new data file is created, or if other options are changed).

## Calculations

A Calculation is an output in a Document, created as follows:

**Calculation > Custom Code >**click page**.**- Enter code written in the
*R Language*under**R CODE**. This code can be used to create tables, visualizations or any other calculations. **Show raw R output**

## R Variables

An *R Variable* is a variable in a Data Set, created as follows:

**Anything > Data > Variables > New > Custom Code > R - Numeric**or**R - Text.**- Enter code written in the
*R Language*under**R CODE**. This code should create tabular data with the same number of observations as in the data file.

## R Data Sets

An *R Data Set* can be added to a project by doing the following:

**Data Sets > Plus (+) > R**or**Anything > Data > Data Sets > Add**.- These data sets need to have a tabular structure.

## Standard R

It is possible to do just about any form of data analysis using R by writing code. Where we think analyses are likely to be used by many of our users, we have made it available via a graphical user interface (i.e., menus and/or buttons and the like, without needing to write code). We refer to the analyses that we have made available via a graphical user interface as *Standard R*.

Note, that R code in a *Standard R* object can be further edited via **Properties > R CODE**.

## Updating

R code is automatically re-run whenever:

- Data or outputs that are inputs into R calculations are changed (unless
**Properties > R CODE > Automatic**is un-checked in the**object inspector**), for example, by being recoded, or, when the data file that is the source data for a Data Set is changed. - The R code contains instructions for updating at a specified frequency.

## R Behavior

R variables and calculations have additional R code behavior:

- Whenever you reference a table or Calculation, the reference will highlight in blue.
- When referencing variables, it will highlight in yellow.
- In both cases, when you hover over the reference it will provide a preview.
- By clicking the object name in the preview, Displayr will then take you to the source object, for example to a
**Page**where a table exists or to the**Data Sets**tree where the variable exists. - You can also hover over an R function to see the relevant Help documentation.
- When referencing other variables, any categories that have been merged in the related table will instead flow through via R, and any that have been removed will be excluded.

## R Limitations

- When referencing default tables, R can only pull in statistics from
**Inputs > STATISTICS > Cells**. The**Right**and**Below**statistics are not recognized, but you can add the equivalent as**Cells**statistics in order to reference these. - When referencing default tables, R is unable to bring in significance results from the
**Arrows and Font colors**setting. - When referencing nested default tables, R is unable to bring in span labels, only the lowest level labels.
- When importing R data sets, R is unable to bring in variable labels as R does not have the concept of both
**Name**and**Label**. This means each variable will be labeled using the variable name. - Calculations and R data sets are by default restricted to 67MB.

## See Also

How R Works Differently in Displayr Compared to Other Programs

How to Import a Data Set Using R

How to Create a Custom Numeric R Variable

How to Create a Custom R Text Variable

How to Add a Custom Calculation

How to Work with R Data Types and Structures

How to Reference and Distinguish between Different R Objects in Displayr

How to Work with Conditional R Formulas

How to Perform Mathematical Calculations Using R

How to Work with Regular Expressions Using R

How to Use R's Paste Formulas in Displayr

How to Extract Information from an R Object

How to Troubleshoot R Code in Displayr

## Comments

0 comments

Article is closed for comments.