HexLibraryHexLibrary
</> HexCodeSign inSign up
PythonJavaScriptTypeScriptCC++JavaPHPGoRustRubyBashSQLLuaPerlCOBOLPascalDelphiFortranDartSwiftC#JuliaGroovyRElixirHaskellKotlinScalaClassic ASPClipperMS-DOS
LESSONS
Introduction to RVariablesData TypesOperatorsCharacters (character)VectorsConditions (if / else)Loops (for / while)Functions
REFERENCE
📖 Overview
🖥️ Output
📦 Variables & Types
🔢 Numbers & Math
✍️ Character
📚 Vector
🔀 Condition & Loop
🧩 Function

R lessons

Statistics and data analysis

R was designed in 1993 by statisticians, for statisticians. Rather than being a general-purpose language, it is an environment built around analyzing and visualizing data. That's why reading a data table, getting summary statistics, or drawing a chart are single-line tasks in R.

The distinguishing power of R is the depth of its statistical packages. There are over twenty thousand packages in the CRAN archive, and a new statistical method published in academia is usually released as an R package first. Charts produced with ggplot2 have become the standard for scientific publications.

What sets R apart from Python is focus. Python is a general-purpose language and data science is one of its application areas; since R was designed for data from the ground up, it offers a more natural language for statistical modeling and visualization. On the other hand, you don't write web applications or system software with R.

📖 Command Reference→
  • •

    Introduction to R

    First step into R, the language of statistics and data science: printing to the screen with cat and comments.

    →
  • •

    Variables

    Assigning values with <-; types are inferred from the value, and values can be changed.

    →
  • •

    Data Types

    numeric, character, logical types; combining (paste0) and text↔number conversion.

    →
  • •

    Operators

    Math (+ - * / %/% %% ^), comparison (== != < >) and logic (& | !).

    →
  • •

    Characters (character)

    Length (nchar), uppercase/lowercase, searching (grepl) and replacing (gsub).

    →
  • •

    Vectors

    Creating vectors with c(), 1-based indexing, length (length) and iterating with a loop.

    →
  • •

    Conditions (if / else)

    Making decisions with if-else if-else; conditions in parentheses, blocks in curly braces.

    →
  • •

    Loops (for / while)

    Iterating over ranges (1:5) and vectors with for, conditional repetition with while.

    →
  • •

    Functions

    Definition with function, parameters, return (or last expression) and calling.

    →

What you will learn

  • The vector structure and vectorized operations
  • Holding tabular data with a data frame
  • Reading data from a file and getting basic summary statistics
  • Filtering rows and columns, grouping, and summarizing operations
  • Writing functions and using the apply family
  • Visualizing data with base graphics

Who is this for?

  • Those working with statistics, biostatistics, or econometrics
  • Students and academics conducting academic research
  • Analysts doing data analysis and reporting

When to use?

For statistical modeling, hypothesis testing, academic data analysis, and publication-quality chart production, R is first-class; the scope of statistical packages is unmatched in other languages.

It is not suitable for applications running in a production environment, web services, or general software development. When machine learning models need to be put into production, Python is generally preferred.

Frequently asked questions

Should I learn R or Python?

If your work is heavy on statistical analysis, academic research, and visualization, R gives faster results. If you also need to embed a model into a product, build a data pipeline, or do general software development, Python is more comprehensive. Most people advancing in the data field end up using both together.

What does vectorization mean?

It means applying an operation to the entire vector all at once, rather than element by element with a loop. In R, you don't need to write a loop to multiply a vector by two, you multiply it directly. This is both shorter and much faster; it is the first habit to acquire when learning R.

What is the difference between a data frame and a tibble?

A data frame is R's built-in table structure. A tibble is the modernized version offered by the tidyverse packages: it prints cleaner and doesn't perform unexpected type conversions. The two can largely be used interchangeably.

Why do R indices start at 1?

R follows mathematical and statistical tradition; the first element is number 1. For those coming from Python or C, this is a difference that takes getting used to and is the most common cause of off-by-one errors in loops.

Summary

R is a language specifically designed for statistics and data visualization, which has become a standard in the academic world. In this training, we progress from vectors to data frames, grouping, and chart production.

HexLibraryHexLibrary

Learn programming more clearly. Every command is explained line by line with colors, reinforced with runnable exercises, test your code instantly — all in one place, free.

Learn

  • Home
  • Languages & Lessons
  • HexCode

Company

  • About
  • Contact

Legal

  • Privacy Policy
  • Terms of Use

Other Projects

  • HexToolz
  • Free Service Manuals
© 2026 HexLibrary · The clearest way to learn code