Written and maintained by CASRAI Editorial Board
Last updated
R is a language and environment for statistical computing and graphics, according to the R Project’s own description. Researchers use it to clean and summarise data, fit statistical models, run tests and draw publication-quality plots, usually from a script that can be re-run later. It is free software released under the GNU General Public License and runs on UNIX-like systems, Windows and macOS (R Project, About R, checked 2026-10-29).
What is R programming used for in research?
The manual An Introduction to R describes R as an integrated suite of software facilities for data manipulation, calculation and graphical display. In its words that means an effective data handling and storage facility, a suite of operators for calculations on arrays (in particular matrices), and graphical facilities for data analysis and display. R is also a programming language, with conditionals, loops and user-defined recursive functions (R Core Team, An Introduction to R, section 1.1, checked 2026-10-29).
Because R is highly extensible through add-on packages, most discipline-specific work happens in packages rather than in the base system. The Comprehensive R Archive Network (CRAN) publishes Task Views, which exist to give guidance on which CRAN packages are relevant to a given topic. They are curated lists by topic, not a ranking of the best packages. Views listed on the CRAN Task Views page (checked 2026-10-29) include:
- Clinical research: ClinicalTrials, Survival, MetaAnalysis, Pharmacokinetics
- Epidemiology and health data: Epidemiology, CausalInference, MissingData
- Social science and economics: Econometrics, Psychometrics, OfficialStatistics
- Statistical modelling: Bayesian, MixedModels, TimeSeries, ExperimentalDesign
- Earth and life sciences: Spatial, Environmetrics, Phylogenetics, Omics
- Method and workflow: ReproducibleResearch, NetworkAnalysis
For biological assay data there is a separate project. Bioconductor’s stated mission is to develop, support and disseminate free open source software that facilitates rigorous and reproducible analysis of data from current and emerging biological assays. Most of its components are distributed as R packages, and each Bioconductor release is designed to work with a specific version of R (Bioconductor, About, checked 2026-10-29).
What is RStudio used for?
RStudio is not R. R is the language and its computing engine. RStudio is a separate program, an editor and workspace you use to write and run R code. The CASRAI guide how to use RStudio covers its panes and workflow, so this page stays with R itself.
How to install or access R (official source only)
Get R from the R Project (r-project.org), which links to CRAN. The CRAN bin directory holds separate folders for linux, macos and windows builds, so pick the folder for your operating system and follow the instructions there. Do not install R from third-party download sites. To start R on a UNIX-like system, type R at the shell prompt; the manual notes that q() ends the session and offers to save the workspace.
A first task, step by step
This walk-through uses the faithful data set that ships with R and follows the worked example in section 8.2 of An Introduction to R (checked 2026-10-29).
- Start R. At the prompt, make the built-in data set’s columns available by name:
attach(faithful) - Summarise one variable:
summary(eruptions) - Draw a histogram of the same variable:
hist(eruptions) - Look up any function you do not know with
help(solve)or?solve.help.start()opens the HTML help in a browser, and??solvesearches the help system by keyword. - To use your own data, read a plain-text file whose first line holds the variable names into a data frame:
HousePrice <- read.table('houses.data', header=TRUE)
For your own analysis, keep the commands in a script file and run them with source('commands.R'). A saved script lets you re-run the same analysis later. See the CASRAI entry on computational reproducibility, and renv for recording which package versions a project used.
Output and how to read it
For summary(eruptions) the manual shows this output:
Min. 1st Qu. Median Mean 3rd Qu. Max. 1.600 2.163 4.000 3.488 4.454 5.100
These are the minimum, first quartile, median, mean, third quartile and maximum. Here the median (4.000) sits above the mean (3.488). The manual follows the summary with a stem-and-leaf display and a histogram. The histogram from hist(eruptions) shows how the values are spread across bins.
Troubleshooting
- Columns come in shifted or mislabelled. When the first line of the file is a row of variable names, add
header=TRUEtoread.table, as in step 5. - Help for a symbol or reserved word returns an error. Put the name in quotes, for example
help('[['). This is also needed for words such asif,forandfunction. - You do not know the function name. Search the help pages with
??followed by a keyword, or browse by concept throughhelp.start(). - A package function is not found. Install the package with
install.packages()and load it withlibrary(). Bioconductor packages must match the Bioconductor release for your R version.
Free alternatives
| Software | What its own site says |
|---|---|
| Julia | An open source project made available under the MIT license (julialang.org, checked 2026-10-29). |
| JASP | A free, open-source project supported by the University of Amsterdam (jasp-stats.org, checked 2026-10-29). |
| jamovi | A free and open statistical spreadsheet (jamovi.org, checked 2026-10-29). |
For commercial comparisons, see SPSS vs R and R vs Stata. For a similar tool in a different ecosystem, see what MATLAB is used for.
FAQ
What is R programming used for?
Statistical computing and graphics: data handling, modelling, tests and plots, extended by add-on packages for each discipline.
Is R free?
Yes. R is free software under the GNU General Public License.
Is R the same as RStudio?
No. RStudio is a separate editor for writing and running R code, see how to use RStudio.
What is RStudio used for?
RStudio is an editor and workspace for writing and running R code; it is not the language itself. See how to use RStudio.
Where do I find packages for my field?
Start with the CRAN Task Views for your topic, or Bioconductor for biological assay data.
Sources
- R Project, About R: r-project.org/about.html (checked 2026-10-29)
- R Core Team, An Introduction to R: cran.r-project.org/doc/manuals/r-release/R-intro.html (checked 2026-10-29)
- CRAN Task Views: cran.r-project.org/web/views/ (checked 2026-10-29)
- Bioconductor, About: bioconductor.org/about/ (checked 2026-10-29)
- Julia: julialang.org; JASP: jasp-stats.org; jamovi: jamovi.org (checked 2026-10-29)








