Top 1,000 Features Creators Events Podcasts Extensions Interviews Blog Explorer CSV

R

< >

R is an open source programming language created in 1993 by Ross Ihaka and Robert Gentleman.

#17on PLDB 31Years Old 690kRepos
Homepage · REPL · Try It Online · Download · Blog · Wikipedia · Subreddit · Twitter · FAQ · Release Notes · Docs · Mailing List

R is an open source programming language and software environment for statistical computing and graphics that is supported by the R Foundation for Statistical Computing. The R language is widely used among statisticians and data miners for developing statistical software and data analysis. Polls, surveys of data miners, and studies of scholarly literature databases show that R's popularity has increased substantially in recent years. Read more on Wikipedia...


Example from Riju:
print("Hello, world!")
Example from hello-world:
cat("Hello World")
# Hello World in R cat("Hello world\n")
Example from Linguist:
hello <- function() { print("hello, world!") } hello()
Example from Wikipedia:
install.packages("caTools") # install external package library(caTools) # external package providing write.gif function jet.colors <- colorRampPalette(c("#00007F", "blue", "#007FFF", "cyan", "#7FFF7F", "yellow", "#FF7F00", "red", "#7F0000")) dx <- 400 # define width dy <- 400 # define height C <- complex( real=rep(seq(-2.2, 1.0, length.out=dx), each=dy ), imag=rep(seq(-1.2, 1.2, length.out=dy), dx ) ) C <- matrix(C,dy,dx) # reshape as square matrix of complex numbers Z <- 0 # initialize Z to zero X <- array(0, c(dy,dx,20)) # initialize output 3D array for (k in 1:20) { # loop with 20 iterations Z <- Z^2+C # the central difference equation X[,,k] <- exp(-abs(Z)) # capture results } write.gif(X, "Mandelbrot.gif", col=jet.colors, delay=100)
if else repeat while function for in next break TRUE FALSE NULL Inf NaN NA NA_integer_ NA_real_ NA_complex_ NA_character_ ...

Language features

Feature Supported Example Token
Standard Library
print("Hello, World!")
Conditionals
Functions
While Loops
Booleans TRUE FALSE
Assignment =
Print() Debugging print
Line Comments
# A comment
#
Pipes
# R has pipes via a library like dplyr
starwars %>% filter(species == "Droid")
Operator Overloading
Lazy Evaluation
File Imports
source("filename.r")
Comments
# A comment
Bitwise Operators
! x
x & y
x && y
x | y
x || y
xor(x, y)
Strings
"hello world"
"
Case Insensitive Identifiers X
Semantic Indentation X
Zero-based numbering X
MultiLine Comments X

View source

- Build the next great programming language · About · Resources · Acknowledgements · Part of the World Wide Scroll