data() #BAI HOC SO 1 #CAC THAO TAC CO BAN # 1.CAI DAT CAC GOI PHO THONG
install.packages(“tidyverse”)
library(ggplot2)
library(dplyr) library(tidyr) library(readr) library(readxl)
CO2
View(CO2)
head(CO2)
str(CO2) summary(CO2)
CO2 %>% select(Type, conc)
CO2 %>% filter(conc>500)
——THUC HANH——-
mpg ?mpg
head(mpg)
summary(mpg)
mpg$hwy
mpg %>% filter(hwy>20)
mpg_loc <- mpg %>% select(hwy, cty) %>% filter(hwy>20)
head(mpg_loc)
plot(mpg\(displ,mpg\)hwy)
ggplot(data=mpg) + geom_point(mapping = aes(x = displ, y =hwy, color = mpg$class))
###BTVN tim hieu ve bo Titanic, Iris, diamonds
hangxe <- mpg %>% group_by(manufacturer) %>% summarise(soluong = n())
head(hangxe)
View(hangxe)
namsx <- mpg %>% group_by(year) %>% summarise(soluong = n())
head(namsx)
dem_hx <- table(mpg$manufacturer) dem_hx
hangxe <- mpg %>% group_by(manufacturer) %>% summarise(soluong = n(), tonxang = max (hwy), tietkiem = min (hwy), tb_tieuthu = mean (hwy), trungvi = median(hwy) ) hangxe
loaixe <- mpg %>% group_by(class)%>% summarise(soluong = n(), tonxang = max(hwy), tietkiem = min(hwy), tb_tieuthu = mean(hwy), trungvi = median(hwy))
loaixe
hist(mpg$hwy)
ggplot(data = mpg) + geom_histogram(mapping = aes(x = hwy))
ggplot(data=mpg) + geom_bar(mapping = aes(x=class))
Superstore <- read_excel(“3.SUPERSTORE.xlsx”, sheet = 1)
head(Superstore)
View(Superstore)
Creditdata <- read_excel(“creditdata.xlsx”, sheet = 1)
credit_data <- Creditdata credit_data[is.na(credit_data)] <- 0
names(credit_data) <- gsub(” “,”_“, names(credit_data))
View(credit_data)
theonhom <- credit_data %>% group_by(Term) %>% summarise(soluong = n())
theonhom
ggplot(data = credit_data) + geom_bar(mapping = aes(x = Home_Ownership, color = Term)