Data Science — R
R basics
# Vectors
x <- c(1, 2, 3, 4, 5)
mean(x)
sd(x)
# Data frames
df <- data.frame(name = c("A", "B"), value = c(1, 2))
# Read CSV
df <- read.csv("data.csv")
ggplot2
library(ggplot2)
# Scatter plot
ggplot(df, aes(x = x, y = y)) +
geom_point()
# Line plot
ggplot(df, aes(x = date, y = value)) +
geom_line()
# Bar plot
ggplot(df, aes(x = category)) +
geom_bar()
dplyr
library(dplyr)
# Filter
df %>% filter(value > 5)
# Select
df %>% select(name, value)
# Arrange
df %>% arrange(desc(value))
# Summarize
df %>% group_by(category) %>% summarize(mean_value = mean(value))
Statistics
# T-test
t.test(group1, group2)
# Linear regression
model <- lm(y ~ x, data = df)
summary(model)
Mini Practice
- Create data frames
- Visualize with ggplot2
- Manipulate with dplyr
- Perform statistical tests
Up Next
Continue with Tableau - Data visualization tool.
Related Topics
Frequently Asked Questions about R
What is R in Data Science?
R is a fundamental concept in Data Science. This lesson explains it step by step with clear examples, making it easy for beginners to understand.
How do I learn R?
Start by reading the explanation above, then try the code examples. Practice by modifying the examples and experimenting with different values. Hands-on practice is the best way to learn R.
Why is R important in Data Science?
R is essential for Data Science development. Understanding this concept will help you write better code and solve real-world problems more effectively.