Introduction
If you're starting your journey with R, the fastest way to learn is by experimenting with small, simple code snippets. In this post, I’m sharing three beginner‑friendly examples taken from my book R Programming for Absolute Beginners. Each snippet is short, practical, and designed to help you build confidence quickly.
Let’s jump in.
A simple print statement is often the first step in learning any programming language.
print("Hello, R!")
What it does:
Displays a message in the console.
Why it matters:
It teaches you how R outputs text and confirms your environment is working.
- Create a Numeric Vector Vectors are one of the core data structures in R. Here’s how to create one:
numbers <- c(1, 2, 3, 4, 5)
numbers
What it does:
Creates a vector of numbers and prints it.
Why it matters:
Vectors are used everywhere in R — data analysis, statistics, machine learning, and more.
- Calculate the Mean Once you have a vector, you can perform basic calculations easily.
numbers <- c(10, 20, 30, 40, 50)
mean(numbers)
What it does:
Computes the average of the values.
Why it matters:
This introduces you to R’s built‑in functions, which are extremely powerful for data analysis.
r
beginners
programming
tutorial
data science
You can continue your R journey with my full book here:
https://artifactcentral.org/landing-page
https://books2read.com/R-Thestoryteller
Learning R doesn’t have to be complicated. Small, simple snippets like these help you build confidence quickly and understand the language step by step.
Top comments (1)
Thanks for reading! If you’re starting with R and want more simple, practical examples, my book goes deeper with step‑by‑step snippets and explanations. Happy learning.