đ What is R?
R is a free and open-source programming language and software environment designed for statistical computing, data analysis, and data visualization. It is widely used by data scientists, statisticians, researchers, and analysts to analyze data, build predictive models, and create high-quality visualizations.
Information
đ Why Learn R?
- Simple syntax for statistical analysis.
- Excellent support for data visualization.
- Thousands of community-contributed packages.
- Strong ecosystem for machine learning and data science.
- Widely used in academia and industry.
đ§ Features of R
âī¸ Installing R
đ Your First R Program
The traditional first program prints a message to the console using the print() function.
Hello World in R
print("Hello, World!")đĸ Variables in R
Variables store values using the assignment operator <-. Although = can also assign values, <- is the preferred style in R.
Variable Example
name <- "Alice"
age <- 24
salary <- 45000
print(name)
print(age)
print(salary)đ Basic Data Types
| Data Type | Description | Example |
|---|---|---|
| Numeric | Numbers | 25.5 |
| Integer | Whole numbers | 10L |
| Character | Text | "Hello" |
| Logical | Boolean values | TRUE |
| Complex | Complex numbers | 3 + 2i |
đ§Ž Basic Arithmetic
Arithmetic Operations
a <- 10
b <- 5
a + b
a - b
a * b
a / b
a ^ b
a %% bđĻ Common Data Structures
A vector stores elements of the same data type.
Vector
numbers <- c(10, 20, 30, 40)
print(numbers)A matrix is a two-dimensional collection of similar data.
Matrix
m <- matrix(1:9, nrow = 3)
print(m)A data frame stores tabular data where each column may have a different type.
Data Frame
students <- data.frame(
Name = c("Alice", "Bob"),
Age = c(21, 22)
)
print(students)A list stores multiple objects of different types.
List
info <- list(
name = "Alice",
age = 22,
marks = c(90, 85, 88)
)
print(info)đ Built-in Functions
Useful Functions
numbers <- c(10, 20, 30, 40, 50)
sum(numbers)
mean(numbers)
max(numbers)
min(numbers)
length(numbers)đ Simple Plot
One of R's strengths is its ability to generate beautiful visualizations with minimal code.
Basic Plot
x <- c(1,2,3,4,5)
y <- c(2,4,6,8,10)
plot(x, y, type="b", col="blue")đ¯ Real-World Applications
- đ Business analytics
- đš Financial modeling
- đ§Ŧ Bioinformatics
- đĨ Healthcare research
- đ¤ Machine learning
- đ Data visualization
đĄ Best Practices
Best Practice
đ Learning Roadmap
đ Summary
R is one of the most powerful programming languages for data analysis, statistics, and visualization. Its rich package ecosystem, extensive community support, and ease of use make it an excellent choice for beginners as well as experienced data professionals. Mastering the fundamentals of R provides a strong foundation for advanced topics such as machine learning, data engineering, and statistical modeling.