.R

R File

R Script File
Ask a question
QUICK ANSWER

An R file is source code written in R, a language built for statistical computing and data science. Open it with RStudio (free) or run it from the command line using "Rscript filename.R". Do not run R scripts from unknown sources without reading them first -- they can execute arbitrary commands on your system.

Developer: R Core Team (R Foundation for Statistical Computing); R language created by Ross Ihaka and Robert Gentleman (1993) Category: Developer Files Open standard MIME: text/x-r-source
OPENS ON Windows macOS Linux Web
Related: .DO · .MD · .HEX · .XSD

On this page

19k+ extensions indexed
Last reviewed Aug 19, 2026

Not sure what your file is?

Drop any file into our identifier - we read just the first bytes to name the format.

Identify a file

What is the R file format?

.r files (conventionally written as .R with an uppercase letter) contain source code for the R statistical programming language, created by Ross Ihaka and Robert Gentleman at the University of Auckland in 1993. R is the dominant language for statistical computing, bioinformatics, and data science in academic and scientific research.

An .R script is plain UTF-8 text with no mandatory structure - statements execute top-to-bottom, or define functions for later loading via source(). Typical scripts begin with library() calls to load packages, use the <- operator for assignment, apply tidyverse or base-R data manipulation, fit statistical models with functions such as lm() or glm(), and generate visualizations through ggplot2 or base graphics. Comments are prefixed with #. Scripts run from the command line with Rscript script.R or interactively inside RStudio. On Unix systems the shebang #!/usr/bin/env Rscript allows direct execution.

A practical annoyance: on case-sensitive file systems (Linux, macOS) .R and .r are distinct files. GitHub Linguist historically misidentified .r as REBOL rather than R; REBOL's community has since shifted toward .reb and .r3 extensions to reduce ambiguity. Related formats include R Markdown (.rmd) for literate programming and RData (.rdata) for serialized R objects.

Security & safety

RISK: MEDIUM

R scripts are interpreted code - executing an untrusted .R file can perform arbitrary file system operations, make network requests, and install packages. Before running a script from an unknown source, open it in a text editor to review its contents. R code can call system() and shell() to execute OS commands. Treat unknown .R files like any other executable script.

Format details

in a nutshell
FULL NAMER Script Fileaka R source file, R program file
DEVELOPERR Core Team (R Foundation for Statistical Computing); R language created by Ross Ihaka and Robert Gentleman (1993)since 1993 (R language); .R extension used since R's public availability (~1995)
MIME TYPEtext/x-r-source
TYPEPlain-text source code file for the R statistical programming language
STANDARDOpen · royalty-free
This extension is also used by…
  • REBOL Script - REBOL (Relative Expression Based Object Language) historically used .r; community now prefers .reb / .r3 to avoid confusion with R statistical scripts.

Programs that open R files

Windows4 apps
Notepad Open-source View/edit the script with R syntax highlighting (may need to manually set language to R).
RStudio (Posit) Open-source Open .R file from File → Open File, or drag onto the editor. Runs code with Ctrl+Enter (line) or Source button (whole file).
R (base installation) Open-source Install R from CRAN; run a script from CMD: 'Rscript C:\path\to\script.R'. Or open R GUI and use File → Source R code.
VS Code with R extension Open-source Install the R extension in VS Code; provides syntax highlighting, R terminal integration, and plot viewer.
macOS4 apps
Apple Xcode Free Can view .R text files as plain text, but provides no R language support or execution. Not a recommended tool for R scripts.
BBEdit Freemium Can open and display .R files as text with basic syntax coloring; no execution capability.
RStudio (Posit) Open-source Same as Windows - open .R file in RStudio editor, run with Cmd+Enter or Source.
R (base) Open-source Install R from CRAN; in Terminal: 'Rscript script.R'. R.app GUI also available.
Linux2 apps
RStudio (Posit) Open-source Available for major Linux distros; same workflow as Windows/macOS.
R (base) Open-source Install from distribution repos or CRAN; run: 'Rscript script.R' in terminal.
Web1 app
Posit Cloud (formerly RStudio Cloud) Freemium Upload .R file to a Posit Cloud project and run it in a browser-based RStudio environment - no local R install needed.

Technical details

deep spec
Text encodingUTF-8 (recommended and default in modern R); ASCII or system locale accepted by older versions
Comment syntax`#` prefix for line and inline comments; no block comment syntax in base R
Assignment operator`<-` (canonical R style); `=` is valid but conventionally reserved for function argument passing
Case sensitivityOn case-sensitive file systems (Linux, macOS) `.R` and `.r` are distinct; GitHub Linguist may misclassify `.r` as REBOL
Execution methods`Rscript script.R` from the command line; `source("script.R")` within an R session; interactive REPL in RStudio
Shebang support`#!/usr/bin/env Rscript` on the first line enables direct Unix execution when the file is marked executable
Package system`library(pkgname)` imports packages; over 20,000 packages on CRAN; Bioconductor for genomics workflows
No mandatory structureNo required `main()` function or module declaration; execution proceeds top-to-bottom
Typical file sizeUnder 100 KB for most analytical scripts; can reach several MB if large data vectors are embedded as literals
Dominant IDERStudio (Posit) - provides syntax highlighting, integrated REPL, plot viewer, and package management for `.R` files
Ecosystem rolesStatistical modeling (`lm()`, `glm()`), data wrangling (dplyr, tidyr), visualization (`ggplot2`), bioinformatics (Bioconductor)
Reproducibility practice`set.seed()` for stochastic reproducibility; `sessionInfo()` to record the runtime environment for published analyses
Released1993 (R language); .R extension used since R's public availability (~1995)
Latest versionR 4.4.x (2024); language and .R format unchanged in structure
Open standardYes · royalty-free
Specificationwww.r-project.org

R conversions

Community Q&A

asked by users
Ask a quick question
Get help from people who work with R files. Be specific - include your system and software version.
No account needed · answers usually within a day

No questions yet - be the first to ask about R files.

Frequently asked questions

What is an .R file?
A script written in R - a programming language for statistics and data science. You need R (free from cran.r-project.org) and ideally RStudio to open and run it.
How do I open an .R file?
Install R and RStudio (both free). Open RStudio, then use File → Open File to load the .R script. You can also view it in any text editor (Notepad, VS Code).
How do I run an R script?
In RStudio: open the file and click 'Source', or press Ctrl+Shift+S. From the command line: 'Rscript yourscript.R'. In R GUI: use File → Source R code.
Why does my editor show REBOL highlighting for .R files?
Some older editors (Notepad++, some GitHub tools) historically defaulted .r to REBOL. Change the language/syntax mode to 'R' manually. Modern versions of these tools have fixed this.
Can I convert an R script to Python?
Not automatically. You need to manually translate R functions to Python equivalents (pandas for data frames, statsmodels for statistics, matplotlib/seaborn for plots). The rpy2 library lets you call R from Python as a bridge.
Is R the same as R Studio?
No. R is the programming language and runtime; RStudio (now Posit) is an IDE (Integrated Development Environment) that makes writing and running R code much easier. R must be installed separately from RStudio.

References

1R Project - The R Foundation for Statistical Computingwww.r-project.org
2CRAN - Comprehensive R Archive Networkcran.r-project.org

Keep exploring

across the database

Top extensions this week

1.AQQAQQ Instant Messenger File
2.CRDOWNLOADChrome Partial Download File
3.PARTPartial Download File
4.BINCD/DVD Disc Image (BIN/CUE)
5.RPMSGRestricted Permission Message
6.MDMarkdown Document
7.NOMEDIAAndroid No-Media Marker File
8.PRO6XProPresenter 6 Bundle File
9.PRDXSoftMaker Presentations Document
10.EXEWindows Executable (Portable Executable)

Related extensions

.DOStata Do-File
.MDMarkdown Document
.HEXIntel HEX File
.XSDXML Schema Definition
.MAPSource Map (JavaScript / CSS)
.CONFIGConfiguration File

Free file tools

An in-browser file identifier and image converter - everything runs on your device.

Open the toolbox

Browse file extensions A-Z