Published on
· July 10, 2026

The R language: what it is, what it is for, and how to get started

Blog
  • Photo of Renata Weber
    Renata Weber
    Renata Weber
    Growth Specialist at Pareto Plus

    Growth Specialist at Pareto Plus

A person's hands programming with the R programming language on a notebook

R is an open-source programming language geared toward statistical computing and data visualization, used in data science, academic research, and business analysis. Maintained by the R Foundation, it runs on Windows, Linux, and macOS and bundles thousands of free packages in its official repository.

What is the R language?

The R language is an open-source language and software environment for statistical analysis and graphics, created by statisticians Ross Ihaka and Robert Gentleman at the University of Auckland as a free implementation of the S language. The official definition sums it up well: according to the R Project site, "R is a free software environment for statistical computing and graphics".

In practice, R was designed by statisticians for statisticians: vectorized operations, native statistical models, and publication-quality charts are part of the language's core, without depending on external libraries. The project remains active — version R 4.6.1 ("Happy Hop") was released on June 24, 2026, according to R Project itself.

The heart of the ecosystem is CRAN (Comprehensive R Archive Network), the official repository that in July 2026 gathered 24,241 available packages for data manipulation, modeling, graphics, and reports. This abundance of ready-made packages explains why the data science community adopts R as a standard tool for statistical analysis and modeling.

What is the R language for?

The R language is used to explore, model, and visualize data. It runs everything from simple descriptive statistics to complete predictive models, and also generates analytical web applications. The most common uses are:

  1. Statistical analysis: hypothesis testing, ANOVA, linear regression and logistic regression, time series analysis, and clustering.
  2. Data visualization: the ggplot2 package produces publication-quality scientific charts in a few lines of code.
  3. Machine learning: frameworks like caret and tidymodels standardize the training and validation of machine learning models.
  4. Biostatistics and research: the Bioconductor project concentrates packages for genomics and computational biology, one of R's strongest niches.
  5. Reports and dashboards: R Markdown and Quarto generate reproducible reports; the Shiny framework turns scripts into interactive web applications.

This last point brings R closer to backend development: with Shiny and the plumber package, an R script becomes an API consumed by other systems, without leaving the statistical environment.

How does programming in R work in practice?

Programming in R works interactively: you write expressions in a console, the interpreter executes them right away and returns the result, which makes the data exploration cycle very fast. Three fundamentals are enough to get started: variables, control structures, and data structures like vectors and data frames.

Hello World in R

The traditional first program in R takes a single line:

cat("Hello, World!")

Variables and assignment

In R, you create variables to store data. Assignment is done with the <- operator (the most idiomatic) or with =:

idade <- 30
nome <- "Renata"

Control structures

R supports control structures, like conditionals and loops, to direct the program's flow:

if (idade > 18) {
    cat("Você é maior de idade.")
} else {
    cat("Você é menor de idade.")
}

Vectors and data frames

Vectors are R's fundamental objects: almost every operation is vectorized, that is, applied to all elements at once. Data frames are two-dimensional tables, equivalent to a spreadsheet, and are the central structure of data analysis in the language:

numeros <- c(1, 2, 3, 4, 5)
dados <- data.frame(nome=c("Henrico", "Renata", "Brendow"), idade=c(25, 30, 35))

What is RStudio and why use it?

RStudio is the most popular IDE (Integrated Development Environment) for programming in R, today maintained by Posit and available for free on the official download page. It brings together in a single interface the code editor, the interactive console, the graphics panel, and the environment's variable inspector.

For those learning, RStudio reduces the initial friction: function autocomplete, integrated documentation help, visual debugger, and buttons to install CRAN packages without memorizing commands. For those already working with data, it adds native support for R Markdown, Quarto, and Shiny, as well as Git integration to version analyses like any software project.

R vs Python: which to choose for data science?

Choose R for deep statistical work and visualization; choose Python for projects that mix data with software engineering and generative AI (Artificial Intelligence). In general popularity, Python dominates: in the Stack Overflow Developer Survey 2025, 57.9% of respondents use Python, against 4.9% who use R. Popularity, however, is not the only criterion — in biostatistics, epidemiology, and academic research, R remains the de facto standard.

CriterionR languagePython
Main focusStatistics and data visualizationGeneral purpose, web, and AI
Usage (Stack Overflow 2025)4.9% of respondents57.9% of respondents
Package ecosystemCRAN, curated and data-focusedPyPI, broader and more generalist
Visualizationggplot2 and Shiny, native to the cultureMatplotlib, Plotly, and Streamlit
Strong nichesAcademia, biostatistics, and financeSoftware industry and deep learning
Curve for analysisVery fast for statisticsFast, requires external libraries

In doubt, learn the fundamentals of one of them deeply: the concepts of data manipulation, modeling, and validation transfer well between the two languages.

R code examples for data analysis

The two examples below show the typical R flow: load a CSV file, calculate statistics, and display results.

Example 1: climate data analysis

This example uses climate data to calculate the mean, median, and standard deviation of temperature at a location over a period:

dados_climaticos <- read.csv("dados_climaticos.csv") # carregar os dados climáticos

media_temperatura <- mean(dados_climaticos$temperatura) # média
mediana_temperatura <- median(dados_climaticos$temperatura) # mediana
desvio_padrao_temperatura <- sd(dados_climaticos$temperatura) # desvio padrão

cat("Média da temperatura: ", media_temperatura, "\n")
cat("Mediana da temperatura: ", mediana_temperatura, "\n")
cat("Desvio padrão da temperatura: ", desvio_padrao_temperatura, "\n")

Note that the statistical functions mean(), median(), and sd() are native to the language — no extra package was installed.

Example 2: sales data analysis

In this example, the R language calculates total revenue, the sales average, and the growth percentage compared to the previous year:

dados_vendas <- read.csv("dados_vendas.csv") # carregar os dados de vendas

receita_total <- sum(dados_vendas$valor_vendas) # receita total
media_vendas <- mean(dados_vendas$valor_vendas) # média de vendas

vendas_ano_anterior <- dados_vendas$valor_vendas[1:11]
vendas_ano_atual <- dados_vendas$valor_vendas[12:22]
crescimento <- ((sum(vendas_ano_atual) - sum(vendas_ano_anterior)) / sum(vendas_ano_anterior)) * 100 # crescimento anual

cat("Receita Total: $", receita_total, "\n")
cat("Média de Vendas: $", media_vendas, "\n")
cat("Crescimento em relação ao ano anterior: ", crescimento, "%\n")

The same pattern — load, transform, summarize — repeats in much larger analyses, just with more packages involved.

Conclusion

The R language does not dispute the position of generalist language with Python — and it doesn't need to: as a tool specialized in statistics, it delivers in a few lines what other languages require libraries and configuration to do. If your work involves serious statistical analysis, research, or data visualization, mastering R with RStudio is a direct investment in your productivity; here at CodeCrush, the practical recommendation is to start with data frames and ggplot2, which concentrate most of the language's value in day-to-day work.

## faq

Frequently asked questions

What is the R language for?

The R language is used for statistical analysis, data visualization, and predictive modeling. Researchers, analysts, and data scientists use it for regression, time series, biostatistics, and reproducible reports. With packages like ggplot2, dplyr, and Shiny, R covers everything from data cleaning to interactive dashboards published on the web.

R vs Python: which to choose for data science?

Choose R when the focus is advanced statistics, visualization, and academic research; choose Python when the project involves software engineering, system integration, and deep learning. In the Stack Overflow Developer Survey 2025, Python appears with 57.9% usage and R with 4.9%, but R remains the benchmark in statistical analysis.

Is it worth learning R in 2026?

Yes, in specific niches. R remains strong in biostatistics, epidemiology, quantitative finance, and academia, and the ecosystem is active: CRAN exceeds 24 thousand packages and version R 4.6.1 was released in June 2026. For generalist data jobs, however, Python is usually more demanded.

What is CRAN?

CRAN (Comprehensive R Archive Network) is the official package repository for the R language, maintained by the community and mirrored on servers worldwide. In July 2026 it gathered 24,241 available packages, all subject to automatic quality checks before publication, with standardized installation via install.packages().

Is R hard to learn?

For analysis tasks, no: with a few lines you import a CSV, calculate statistics, and generate charts. The curve rises in object-oriented programming and metaprogramming, areas where R has particularities. Those who already master programming logic usually produce useful analyses in a few weeks of study.

## continue lendo

Keep browsing

About the author

Photo of Renata Weber

Renata Weber

Growth Specialist at Pareto Plus · Grupo Voitto

See profile and all articles