HappiomHappiom
  • Self-Improvement
  • Relationship
  • AI for Life
  • Apps
  • Tech
  • More
    • Online Diary
    • Glossary
  • Learn
    • Book
    • >> Soft Skills
    • Time Management
    • >> Tech Skills
    • R
    • Linux
    • Python
  • Our Apps
    • Download Diary App
    • Write Your First Diary
    • Login to Online Diary App
    • 100K+ Famous Quotes Site
  • Resources
    • Self-Improvement Guide
      • 21-Days to Self-Improvement
      • Creating a Habit
      • Learn Life Experiences
      • Easily Prioritizing Tasks
      • Learning from Mistakes
      • Doing Regular Exercises
      • Setting Priority for Success
      • Avoiding Common Mistakes
      • Eating Healthy Food Regularly
    • Journaling Guide
      • Online Diary
      • Best Diary Apps
      • Diary Writing Ideas
      • Diary Writing Topics
      • Avoid Writing in Diary
      • Diary Writing as Hobby
      • Reasons to Write a Diary
      • Types of Feelings In Diary
      • Improve Diary Writing Skills
  • Self-Improvement
  • Relationship
  • AI for Life
  • Apps
  • Tech
  • More
    • Online Diary
    • Glossary
  • Learn
    • Book
    • >> Soft Skills
    • Time Management
    • >> Tech Skills
    • R
    • Linux
    • Python
  • Our Apps
    • Download Diary App
    • Write Your First Diary
    • Login to Online Diary App
    • 100K+ Famous Quotes Site
  • Resources
    • Self-Improvement Guide
      • 21-Days to Self-Improvement
      • Creating a Habit
      • Learn Life Experiences
      • Easily Prioritizing Tasks
      • Learning from Mistakes
      • Doing Regular Exercises
      • Setting Priority for Success
      • Avoiding Common Mistakes
      • Eating Healthy Food Regularly
    • Journaling Guide
      • Online Diary
      • Best Diary Apps
      • Diary Writing Ideas
      • Diary Writing Topics
      • Avoid Writing in Diary
      • Diary Writing as Hobby
      • Reasons to Write a Diary
      • Types of Feelings In Diary
      • Improve Diary Writing Skills
Expand All Collapse All
  • R Tutorial for Beginners
    • Statistical functions and distributions in R
    • Graphics Plotting functions in R
    • Graphics devices and parameters in R
    • Read and Write Data Stored by Statistical Packages in R
    • Utility Functions in R
    • Datasets in R
    • Methods for S3 and S4 generic functions in R

R Tutorial for Beginners

R is a powerful programming language and environment primarily used for statistical computing and graphics.

I’ll explain you the important basic functions and data types in R along with easy to understand examples.

Basic Data Types

1. Numeric (double)

This data type represents real numbers and is the default type for storing numerical values.

# Numeric data type example
x <- 3.14
y <- 42.0

2. Integer

Integers are whole numbers without a fractional component.

# Integer data type example
z <- 10L # 'L' suffix indicates an integer

3. Character (string)

Character data type is used to represent text.

# Character data type example
name <- "John Doe"

4. Logical (Boolean)

Logical data type represents Boolean values `TRUE` or `FALSE`.

# Logical data type example
is_valid <- TRUE

5. Complex

Complex data type consists of two components: real and imaginary parts.

# Logical data type example
is_valid <- TRUE

Basic Functions

1. print()

Prints its argument.

# print() function example
print("Hello, World!")

2. c()

Concatenates its arguments.

# c() function example
numbers <- c(1, 2, 3, 4, 5)

3. seq()

Generates sequences of numbers.

# seq() function example
sequence <- seq(1, 10, by = 2) # Generates sequence from 1 to 10 by 2

4. rep()

Replicates values.

# rep() function example
repeated <- rep("hello", times = 3) # Repeats "hello" 3 times

5. length()

Returns the number of elements in a vector.

# length() function example
vec <- c(1, 2, 3, 4, 5)
length(vec) # Returns 5

6. sum()

Computes the sum of values.

# sum() function example
sum_of_values <- sum(1, 2, 3, 4, 5) # Returns 15

7. mean()

Computes the mean of values.

# mean() function example
average <- mean(1, 2, 3, 4, 5) # Returns 3

8. max() and min()

Return the maximum and minimum values respectively.

# max() and min() function examples
max_value <- max(1, 2, 3, 4, 5) # Returns 5
min_value <- min(1, 2, 3, 4, 5) # Returns 1

These are just a few examples of basic functions and data types in R which are important to learn.

As we learn R further, I’ll will take you through a wide range of functions and data structures tailored to statistical analysis and data manipulation.

Related Articles
  • Methods for S3 and S4 generic functions in R
  • Datasets in R
  • Utility Functions in R
  • Read and Write Data Stored by Statistical Packages in R
  • Graphics devices and parameters in R
  • Graphics Plotting functions in R

No luck finding what you need? Contact Us

Up Next
Statistical functions and distributions in R
  • About Us
  • Contact Us
  • Archive
  • Hindi
  • Tamil
  • Telugu
  • Marathi
  • Gujarati
  • Malayalam
  • Kannada
  • Privacy Policy
  • Copyright 2025 Happiom. All Rights Reserved.