Data Visualization with R.pdf

Data Visualization in R Cheat Sheet

R Cheatsheet

🌵 ดาวน์โหลด cheatsheet ของ R/ RStudio ได้ที่ https://www.rstudio.com/resources/cheatsheets/

Tip ในการเลือกใช้ chart ในทางสถิติ (รวมถึง ggplot2 ใน R)

Untitled

Why we need Data Viz?

Untitled

Untitled

<aside> 💡 หน้าตาของกราฟไม่เหมือนกันเเต่มี ค่าสถิติ เหมือนกัน ดังนั้นเราควรจะplot Chart ดูด้วยเพื่อที่เราจะได้หน้าตสที่เเท้จริงของข้อมูล

</aside>

Untitled

<aside> 💡 การเปลี่ยนข้อมูลดิบให้เป็นภาพทำได้เราเห็นในสิ่งที่เราไม่คิดว่าจะได้เห็น

</aside>

Untitled

<aside> 💡 cholera คือ โรคอหิวา เมืองBroad streetที่ประเทศอังกฤษ

</aside>

Untitled

## library tidyverse
library(tidyverse)

## basic plots (base R)

hist(mtcars$mpg)

## Analyzing horse power
## Histogram - One Quantitative variable
hist(mtcars$hp)
mean(mtcars$hp)
median(mtcars$hp)

str(mtcars)       
mtcars$am <- factor(mtcars$am,  ##  เปลี่ยนcolumn Am จาก 0,1 ให้เป็น Auto,manual
                    levels = c(0,1),
                    labels = c("Auto", "Manual"))

ทำ chartง่ายๆเอาไว้ดูคนเดว

Histogram

Untitled