สวัสดีผู้อ่านทุกท่านนะครับ ในการเขียน Introduction อันนี้ขอเขียนไม่เป็นทางการนะครับ พอดีเป็นทางการแล้วรู้สึกอึดอัดน่ะครับ 555 ในส่วนของเนื้อหานี้จะเป็นเนื้อหาเกี่ยวกับการทำ Data Visualization in R ผ่านการใช้ Library(tidyverse) เป็นการบ้านที่ทางพี่ทอย แจฮยอน แห่ง DataRockie ได้ให้ทำเพื่อทบทวนความรู้ ดังนั้นได้โปรดกรุณา Sit down and enjoy.
What is Library(tidyverse) ? ⇒ library(tidyverse) is use for helping you to create and plot graphs. but default theme in R is not impressive for me then I use Library(ggtheme)
<aside> 💡 Carat ⇒ Continuous, Price ⇒ Continuous
</aside>
## Relation about carat and price from sample
### pick up sample 500 data from diamonds dataframe
set.seed(21)
dia_sample <- sample_frac(diamonds, 0.01)
ggplot(data = dia_sample,
mapping = aes(x = carat, y = price)) +
geom_point(shape = 23, fill = "blue") +
geom_smooth(method = "lm") +
theme_wsj()

<aside> 💡 Cut ⇒ Discrete, Price ⇒ Continuous
</aside>
diamonds %>%
group_by(cut) %>%
summarize(
mean_price = mean(price)
) %>%
ggplot(aes(x = cut, y = mean_price, fill = cut)) +
geom_col() +
theme_solarized() +
labs(title = "Relationship between Cut and Mean of price",
x = "type of Cut",
y = "price",
caption = "Data Source = diamonds From RStudio")

<aside> 💡 Cut ⇒ Discrete, Clarity ⇒ Discrete
</aside>
diamonds %>%
ggplot(aes(x = cut, y = clarity, color = clarity)) +
geom_count() +
theme_solarized()
