.r File Extension

Learn how to identify and open a .r R or REBOL source file, how Poly supports readable source, and which related formats may be clearer.

File extension details for .r

Full Support
File typeR or REBOL source code
MIME type
EncodingPlain text; UTF-8 is the most portable choice
Operating systemsWindows, macOS, Linux
Opens withRStudio, Visual Studio Code, R, REBOL, Any text editor
Poly supportYes. Poly recognizes .r as readable R source code.
Indexed by PolyYes. Poly indexes readable source for exact and semantic search.
Preview in PolyYes. R source opens in Poly's code editor with syntax highlighting.
Poly agentYes. The Poly agent can read and reason about the source text without executing it.

What kind of file is a .r?

A .r file most often contains source code for the R language, commonly used for statistics, data analysis, and graphics. It is editable text rather than a compiled executable. The file may define functions, load packages, transform data, create plots, or run a complete analysis.

R accepts both .r and uppercase .R for package demos, data scripts, and tests.1 The case matters on case-sensitive filesystems, however, so analysis.r and analysis.R can be two different files. Many projects prefer uppercase .R, while lowercase .r remains valid.

The suffix is ambiguous. REBOL also uses .r for plain-text scripts and recommends .reb where the convention collides with another file type.2 A REBOL script normally contains a REBOL [...] header, while R source does not. That textual clue helps, but there are no fixed magic bytes. Inspect the content before choosing an interpreter.

IANA does not register an R- or REBOL-specific media type, so text/plain is a practical label for these readable files.3

Renaming a Python script, dataset, or notebook to .r does not translate it into R. It only changes the filename and may make an editor select the wrong language mode.

How do I open a .r on my computer?

Any text editor can open .r files on Windows, macOS, or Linux. For R code, RStudio adds an R-aware source editor, console, plots, debugging, and project tools. Visual Studio Code can provide language features through an R extension.

To run a trusted script from a terminal, install R and use:4

Rscript analysis.r

Within an R session, source("analysis.r") reads, parses, and evaluates the expressions in order.5 R uses the session encoding by default, although source() can be given an explicit encoding. UTF-8 is the safest choice for collaboration across current systems.

If the content begins with a valid REBOL header, use a compatible REBOL interpreter instead. REBOL documentation shows REBOL script.r at a shell or do %script.r at its prompt.2

Opening source as text is different from executing it. An unfamiliar script can read or overwrite files, install packages, start programs, and access the network. Review the code and its dependencies before running it.

Poly support for .r

Poly opens .r files in a code-friendly editor with R syntax highlighting, word wrap, and in-file search. It indexes readable source for exact and semantic search, so you can find an object by name or locate code by its purpose. Because .r is ambiguous, a REBOL file may receive R highlighting, but its text remains readable and searchable.

The Poly agent can summarize functions, explain visible transformations, and help reason about an analysis. Poly does not execute the script, install its packages, inspect live objects, or reproduce the R session. Keep relevant source, configuration, and documentation together when those files provide necessary context.

History of .r

Ross Ihaka and Robert Gentleman initially wrote R at the University of Auckland.6 Their 1996 paper described it as a language for data analysis and graphics, and the R Core Team released version 1.0.0 on February 29, 2000.7

R inherited much of its user-facing model from the S language while adding its own implementation and package system. Short source suffixes such as .R and .r fit established S-family conventions. REBOL independently adopted .r as its standard script suffix and documented .reb as a collision-free alternative.2

Choose the file that matches what you need to preserve:

FileBest useImportant difference
.r or .RReviewable scripts and functionsSource only; output and session state are not embedded
.rebREBOL script where .r is ambiguousClearer filename, but older tooling may expect .r
.Rmd or .qmdNarrative analysis with executable codeMixes prose, code, and rendering metadata
.RDataMultiple saved R objectsBinary workspace data, not source code
.rdsOne serialized R objectRead with readRDS(), not source()

Keep .r when a plain, diff-friendly script is the goal. Use a project dependency lockfile when reproducibility depends on exact package versions. Do not rename serialized data to .r; export or reconstruct source code when a human-readable script is required.

Footnotes

  1. R Core Team. Writing R Extensions: Package Structure. Documents .R and .r scripts in package demos, data, and tests, including lowercase test files from R 3.4.0.
  2. REBOL Technologies. REBOL/Core User's Guide: Files. Documents .r as the standard REBOL script suffix and .reb as an alternative where it conflicts with another file type. 2 3
  3. Internet Assigned Numbers Authority. Media Types Registry. The registry contains no R-language-specific media type.
  4. R Core Team. Rscript: Scripting Front End for R. Documents passing a file of R commands to Rscript.
  5. R Core Team. Read R Code from a File, Connection, or Expressions. Explains parsing, sequential evaluation, line endings, and source-file encoding.
  6. R Foundation. R Contributors. Credits Robert Gentleman and Ross Ihaka as R's initial authors.
  7. Chambers, John M. S, R, and Data Science. The R Journal, 2020. Describes R's origins and records the R 1.0.0 release date.
© Poly Corp. 2026