XCODX |

R Online Compiler & Interpreter

Select Language
Online Code Compiler
Full HTML IDE
Py main.py
Program Output Ready
  Welcome to XCODX Online Compiler

  Quick Start:
  Ctrl+Enter  Run code
  Ctrl+S      Save / Download
  Ctrl+L      Clear output

  Select a language and start coding.
Success
Operation completed

About R

R is a language written by statisticians for statistics, created by Ross Ihaka and Robert Gentleman at the University of Auckland in the early 1990s as a free implementation of Bell Labs' S. Vectors, factors, and data frames are built into the language itself, so operations like fitting a linear model or computing a correlation matrix are single function calls rather than library imports. It remains the working language of academic statistics, biostatistics, epidemiology, and pharmaceutical research, and universities across the US, UK, and Australia teach their first statistics courses directly in it. This page runs your script with Rscript on a cloud sandbox — the same non-interactive R that powers batch jobs and CI — inside a live terminal, so console output streams as it computes and readLines pauses for input you type mid-run. Nothing is installed locally; the R version in use is shown in the badge above the editor.

Hello World in R

# Base R only - no CRAN packages required
con <- file("stdin", "r")

cat("Enter exam scores separated by spaces: ")
scores <- scan(con, what = numeric(), nlines = 1, quiet = TRUE)

cat("\nSummary\n-------\n")
print(summary(scores))
cat("Std. dev:", round(sd(scores), 3), "\n")

# One-sample t-test against a hypothesised mean of 70
res <- t.test(scores, mu = 70)
cat(sprintf("\nt = %.3f, df = %.0f, p = %.4f\n",
            res$statistic, res$parameter, res$p.value))

close(con)

When to use R

Reach for R when the task is fundamentally statistical: summarising a dataset, running a t-test or ANOVA, fitting a regression with lm(), or working through a university problem set that expects R output. Base R alone covers a large share of introductory and intermediate statistics coursework — descriptive stats, the distribution functions (dnorm, pbinom, qt), hypothesis tests, and the apply family — and the built-in datasets like mtcars and iris make self-contained practice easy without loading anything. It is a poor fit here for work that depends on the tidyverse or ggplot2, since those live on CRAN and cannot be installed in the sandbox, and for graphics generally, because this is a text-only terminal with no plot device. For quick numeric checks, teaching, and verifying how a function treats NA or factor levels before running it on real data, it is hard to beat.

Common questions

How do I read input from the keyboard in an R script here?

Open the process's standard input with file("stdin") and read from it using readLines(con, n = 1) for a line or scan(con, ...) for numbers; the script pauses at that call until you type into the terminal. The bare stdin() function refers to the R console and does not work under Rscript, which is why file("stdin") is the reliable choice. Output from cat and print appears the instant it runs, so prompt-compute-prompt loops feel like a console session.

Can I install CRAN packages like dplyr, ggplot2, or data.table?

No — install.packages() needs network access and a writable library, and the sandbox has neither, so any library(dplyr) call will fail. Only base R and the recommended packages that ship with every R build are available. Much of what dplyr does has a base equivalent — subset(), aggregate(), tapply(), and merge() — so a surprising amount of coursework still runs unchanged; for package-heavy analysis, prototype the logic here and run the full script in a local R or RStudio.

Which version of R runs, and is it the real interpreter?

It is the genuine R interpreter invoked through Rscript — the same batch front-end used in automated pipelines — running a current R 4.x build, with the exact version shown in the badge above the editor. Base statistics, matrix algebra, the apply family, and the bundled datasets behave identically to a local install; this is real R, not a reduced clone.

Can I create plots or charts, like ggplot2 or plot()?

Not visually. This is a text-only terminal with no graphics device, so plot() and hist() have nowhere to draw, and ggplot2 is not installable anyway. Reframe plotting exercises as numeric output — a table(), summary(), or quantile() often conveys the same result — or generate the figure locally once the underlying logic checks out here.

Does my workspace or any file I write survive between runs?

No. Every run starts with a fresh session and an empty, temporary filesystem, so objects, a saved .RData, and files written with write.csv all disappear when the script finishes. Keep everything the script needs inside the editor — that also makes each run perfectly reproducible.

Should I use R or Python for statistics?

For classical statistics, study design, and reproducible reporting, R tends to feel more natural because tests, models, and data frames are first-class parts of the language; Python is the more general choice when the work extends into web services, broad automation, or deep learning. Both are worth knowing, and you can try Python's take on the same problem from the sidebar. Within this sandbox, R is limited to base functionality, which suits teaching and quick statistical checks well.

How R runs on XCODX

Sandbox filename
main.r
Entry point
single main source file
Editor grammar
r
Reading stdin
readLines("stdin")
Input delivery
live WebSocket stream
Prompt flushing
flush manually before reading input
Compile limit
10 s
Run limit
3 s batch · up to 3 min live
Memory
256 MB per stage
Max source
50,000 characters

Default program on this page

cat("Hello from R!\n")
cat("Welcome to XCODX Online Compiler!\n")
numbers <- c(1, 2, 3, 4, 5)
cat("Sum:", sum(numbers), "\n")