Opens in a new tab

SOFTWARE GUIDE

Getting Started with R for Research
Setup, Data and a Script That Reruns

R rewards a researcher who sets up the workspace once and works from a saved script. Before any statistical tests in R are run, the project needs only a folder, data read with their types checked, and a record of the R and package versions used.

FIRST STEPS

Five Habits Before the First Model

None of these steps involves a statistical test, yet each one decides whether the results that follow can be trusted and repeated.

Getting started with R for research means preparing a workspace, reading data accurately and saving every step in a script before any model is chosen. These R basics for researchers make a first R analysis reproducible from the start, which matters when a committee or a journal asks how a figure was obtained. Once the data are in order, the common tests each have their own guide, such as the independent samples t-test in R, one-way ANOVA in R, the chi-square test in R, Pearson correlation in R and multiple linear regression in R. OnlineSPSS, a specialist statistical consultancy for academic, clinical and professional research, runs and checks analyses in R through an in-house PhD-level statistician, with the research question and its interpretation left to the researcher.

R and RStudio R is the language and the engine that runs the analysis, and RStudio is an integrated development environment that works with it. Install R first, then RStudio, and note the R version, since packages and printed output can differ between releases.

One Project per Study An RStudio project keeps the data, scripts and results of a study in one folder and sets the working directory when it is opened, so file paths do not break when the folder moves to another computer.

Install Once, Load Each Session A package is downloaded once with install.packages() and loaded in every session with library(). Keep a list of the packages used with their versions, because the output of add-on functions can change between releases.

Read Data and Check Types After read.csv() or readr::read_csv(), run str() and summary(). Numbers stored as text, categories left as characters and missing codes such as 999 are found at this stage, and not after the model has run.

A Script, Not the Console Commands typed into the console leave no record. A script that runs from top to bottom in a fresh session shows the analysis can be reproduced, and sessionInfo() records the versions used.

FREQUENTLY ASKED QUESTIONS

Questions About Scripts and Packages in R

A first R project usually stalls on housekeeping rather than statistics: the file format for the work, and a package that installed but will not load.

Either is enough, provided the file runs from top to bottom in a fresh session and reproduces every reported number. A plain script holds the code alone. An R Markdown or Quarto document adds text, tables and figures in one file, which suits a report or an appendix. Whichever is chosen, set any random seed, avoid editing objects by hand in the console, and save the file with the data.

Installing a package does not load it, and a different R version or library location can put it out of reach. Call library() with the exact name, which is case-sensitive, in the session where it is needed. If the error remains, check that RStudio is using the R version where the package was installed, and install it again there. Reinstalling in a loop without that check rarely helps.

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

Setting Up R for
a Research Dataset?

A first analysis is easiest to defend when every number comes from a script that reruns. Support can set up the workspace, the import and the first model with you, or check the files you have built, with the research decisions left in your hands.

No Commitment Required

Strictly Confidential

Fixed Project Fee

In-House PhD-Level Statisticians

Same-Day Response

Serving Researchers Since 2014