library(ggplot2)
install.packages("tidyverse")Installing package into '/cloud/lib/x86_64-pc-linux-gnu-library/4.3'
(as 'lib' is unspecified)
library(tidyverse)── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
✔ dplyr 1.1.4 ✔ readr 2.1.5
✔ forcats 1.0.0 ✔ stringr 1.5.1
✔ lubridate 1.9.3 ✔ tibble 3.2.1
✔ purrr 1.0.2 ✔ tidyr 1.3.1
── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
✖ dplyr::filter() masks stats::filter()
✖ dplyr::lag() masks stats::lag()
ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
library(readxl)
data <- read_excel("/cloud/project/bigdatafin.xlsx", sheet="R_data")
#요양시설 수를 내림차순으로 정렬
count <- data %>%
group_by(location_1) %>%
summarise(요양시설수 = n()) %>%
arrange(desc(요양시설수))
ggplot(count, aes(x = 요양시설수, y = reorder(location_1, -요양시설수))) +
geom_bar(fill = 'pink', stat = 'identity') +
labs(title = '자치구별 요양시설 수', x = '요양시설 수', y = '자치구') +
theme_minimal()+
theme(axis.text.x = element_text( hjust = 1),
plot.title = element_text(size = 16, face = "bold", hjust = 0.5))