Opens in a new tab

What Is RStudio and How It Works
The IDE, the Language and Your Script

What is RStudio? It is an interface for R, not a second statistical program: scripts are edited and run inside it, but every calculation is done by R. Knowing which of the two does what explains most of the surprises in a first analysis.

What You'll Need
R and RStudio both installed
A small dataset to practice on
A folder to hold project files

R AND ITS INTERFACE

What Is RStudio, Pane by Pane and File by File?

The language computes and the interface organizes, and the line between the two decides whether a result can be produced again elsewhere.

What is RStudio in daily use? The RStudio IDE for R is a desktop application in which scripts are edited, code is sent to R, and the console, plots, packages and documentation pages are shown side by side. R, the language and the engine that computes every result, is a separate program, and that is the difference between R and RStudio. Posit, the company that develops RStudio and was called RStudio PBC until 2022, kept the product name. At OnlineSPSS, a specialist statistical consultancy for academic, clinical and professional research, analyses in R are scripted and checked by an in-house PhD-level statistician, and the questions put to the data and the conclusions drawn from them belong to the researcher.

In This Guide

1
Two Programs, Two Versions
2
Four Panes, Four Jobs
3
Memory Is Not a Record
4
Packages Live in a Library
5
Reports From the Same Script
1

Two Programs, Two Versions

R and RStudio are installed and updated separately, so a session has an R version and an RStudio version. The R version is the one that matters for results, and RStudio can be set to use another installed version of R.

Check: Quote the R release in the methods section from R.version.string, and give the RStudio release separately, since the two are numbered independently and a reader may need either.

2

Four Panes, Four Jobs

The Source pane holds scripts, the Console is the live R session, the Environment pane lists the objects held in memory, and a fourth pane switches between files, plots, packages and documentation. Only what a script contains can be rerun later.

Tip: Keep each step in a script file and send it to the console from there with Ctrl+Enter (Cmd+Enter on a Mac), so the console never holds the only copy of a step.

3

Memory Is Not a Record

RStudio can offer to save the workspace on exit and reload it at the next start. A reloaded workspace can hide objects that no script creates, so switching the reload off and restarting R is a common test that a script runs on its own.

Watch: A saved workspace image is not a substitute for the script. Keep the original data file and the script, and treat anything that exists only in memory as disposable.

4

Packages Live in a Library

Add-on packages are installed into a library folder tied to an R version, so moving a script to another computer or release can expose missing or changed packages. For a first project and reading data, see Getting Started with R for Research.

Tip: Load every package with library() in one block at the top of the script. A reader then sees at once which packages the analysis depends on, and a missing one fails early.

5

Reports From the Same Script

Quarto and R Markdown documents combine text and code, and rendering one runs the code in a fresh R process. A report that renders cleanly is therefore a reproducibility check, whether the output is HTML, Word or PDF.

Check: Render the report from a fresh R session, not from one in which you have been experimenting, and compare the rendered tables with those in your draft before the file is shared.

What's Next

A first look at how two measures move together is described under Correlation Analysis (Pearson & Spearman).
A yes-or-no outcome with several predictors leads on to Logistic Regression.
A script you already have can be read through under Independent Statistical Review.

FREQUENTLY ASKED QUESTIONS

Questions About R and RStudio Sessions

Whether the interface is required at all, and why a session behaves differently after a restart, explain much of the confusion between the language and its interface.

No: R runs without RStudio, from a terminal, from another editor or inside a notebook. RStudio adds a script editor, a plot viewer and project and report tools around the same R. A script developed in one environment normally runs in another once its packages are installed there, so the choice of interface is a working preference and does not change the statistics.

Usually the script relied on an object that existed only in memory. An object created in the console, or reloaded from a saved workspace, is visible to the script while the session lasts and disappears when it ends. Restart R, run the script from its first line and add the missing step to the file. If any step draws random numbers, set a seed so the figures repeat.

Your data and project details are handled confidentially, and project information is not published. Researcher names and institutions are not used publicly without permission. An NDA is available where required and can be arranged before sensitive materials are shared. Read more about confidentiality and data security.

You share your research question, design and relevant materials, such as the dataset or the output you have, and a statistically trained Research Coordinator reviews the request and responds the same day. The analysis, deliverables, timeline and one fixed project fee are then confirmed before any work begins, so the timeline follows from the agreed scope.

Still have a question? Find more answers in our full FAQ.

View All FAQs →

NEXT STEP

Is Your R Workflow
Held in a Script?

Reported figures are only as defensible as the script behind them. A working analysis can be rebuilt as a script that reruns from line one, and an existing script can be examined for steps that depend on the session.

No Commitment Required

Strictly Confidential

Fixed Project Fee

In-House PhD-Level Statisticians

Same-Day Response

Serving Researchers Since 2014