본문 바로가기

R

[R] ggplot density chart

Code Ref.

https://www.r-graph-gallery.com/21-distribution-plot-using-ggplot2.html

 

Basic density chart with ggplot2

Learn how to build a basic density chart with ggplot2. Reproducible R code is provided.

www.r-graph-gallery.com

data source

https://raw.githubusercontent.com/holtzy/data_to_viz/master/Example_dataset/1_OneNum.csv

 

# Libraries
library(ggplot2)
library(dplyr)
library(hrbrthemes)

# Load dataset from github
data <- read.table("https://raw.githubusercontent.com/holtzy/data_to_viz/master/Example_dataset/1_OneNum.csv", header=TRUE)

# Make the histogram
data %>%
  filter( price<300 ) %>%
  ggplot( aes(x=price)) +
  geom_density(fill="#69b3a2", color="#e9ecef", alpha=0.8) +
  ggtitle("Night price distribution of Airbnb appartements") +
  theme_ipsum()

'R' 카테고리의 다른 글

[R] correlation  (0) 2021.08.31
[R] ggplot color palette  (0) 2021.08.25
[R package] lubridate  (0) 2021.08.24
[R] category 형 변수 Label encoding  (0) 2021.08.24
[R] data.frame을 클립보드 복사  (0) 2021.08.23