R Programming – Quick Review (Simple & Easy Guide)

R Programming

R is a powerful programming language mainly used for data analysis, statistics, data visualization, and machine learning. It is widely used by data scientists, statisticians, researchers, and analysts.

In this blog, each R topic is explained in one simple line followed by a small example, written in easy English, making it perfect for beginners, students, and interview preparation.

1. What is R?

R is a programming language used for statistical computing and data analysis.

print("Hello R")

2. History of R

R was developed by Ross Ihaka and Robert Gentleman at the University of Auckland.

# R was created in 1993

3. Features of R

R provides powerful tools for data analysis, visualization, and statistical modeling.

summary(c(10,20,30))

4. Applications of R

R is used in data science, finance, healthcare, research, and machine learning.

mean(c(5,10,15))

5. R Program Structure

An R program is written as simple statements executed line by line.

x <- 10
print(x)

6. Variables in R

Variables store data values using the assignment operator <-.

age <- 25

7. Data Types in R

R supports numeric, character, logical, and complex data types.

StructureDescriptionExample
VectorSame data type elementsv <- c(1, 2, 3)
ListDifferent data typesl <- list(1, "R", TRUE)
Matrix2D data (same type)m <- matrix(1:6, nrow=2)
ArrayMulti-dimensional dataa <- array(1:8, dim=c(2,2,2))
Data FrameTable-like structuredf <- data.frame(id=1:3, name=c("A","B","C"))
FactorCategorical dataf <- factor(c("Yes","No","Yes"))
name <- "Krishna"
isPassed <- TRUE

8. Operators in R

Operators perform arithmetic and logical operations.

10 + 5

8.1 Arithmetic Operators

x <- 10
y <- 5

x + y
x - y
x * y
x / y
x %% y

8.2 Relational Operators

x > y
x < y
x == y
x != y

8.3 Logical Operators

x > 5 & y < 10
x > 5 | y > 10
!TRUE

8.4 Assignment Operators

a <- 5
b = 10

9. Conditional Statements

Conditional statements control decision-making in programs.

if (age >= 18) print("Adult")

10. Loops in R

Loops repeat code execution multiple times.

for (i in 1:3) print(i)

11. Functions

Functions are reusable blocks of code.

add <- function(a,b){ a+b }

12. Vectors

Vectors store multiple values of the same type.

v <- c(1,2,3)

13. Lists

Lists store different types of data together.

l <- list(name="Raj", age=21)

14. Matrices

Matrices store data in row and column format.

m <- matrix(1:4, nrow=2)

15. Data Frames

Data frames store tabular data like Excel tables.

df <- data.frame(id=1:3, marks=c(80,90,100))

16. Factors

Factors are used to represent categorical data.

gender <- factor(c("Male","Female"))

17. File Handling

R can read and write data files easily.

write.csv(df,"data.csv")

18. Data Visualization

R provides powerful plotting libraries.

plot(v)

19. Packages in R

Packages add extra functionality to R.

install.packages("ggplot2")

20. Statistical Functions

R is rich in built-in statistical functions.

sd(c(10,20,30))

21. NA and Missing Values

R uses NA to represent missing data.

is.na(NA)

22. Data Manipulation

R can filter and modify data easily.

df$marks[df$marks > 80]

23. R for Machine Learning

R supports machine learning through libraries.

library(caret)

24. Advantages of R

R is free, open-source, and excellent for data analysis.

# Large community support

25. Disadvantages of R

R is slower for large-scale production systems.

# Memory intensive

26. Interview Important Points

R is mainly used for data analysis and visualization.

27. Learning Path for Beginners

Start with basics, learn data structures, then visualization and ML.

28. Conclusion

R is a powerful and beginner-friendly language for data analysis and statistics. Learning R helps you work with real-world data and build strong analytical skills.

Happy Coding with R 📊


Recommended Topics

Leave a Reply

Your email address will not be published. Required fields are marked *