Data Science — Correlation
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 Correlation
What is Correlation in Data Science?
Correlation 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 Correlation?
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 Correlation.
Why is Correlation important in Data Science?
Correlation is essential for Data Science development. Understanding this concept will help you write better code and solve real-world problems more effectively.