Skip to menu

<코드>

 

pop <- read.csv('부주의에+의한+화재발생(소방서별)_20221214144839.csv', header=FALSE, encoding="UTF-8")

pop_header <- pop[1:2,]

pop_header

pop_data <- pop[3:nrow(pop),]

colnames(pop_data) <- c('Firestation1','Firestation2','category','cause','num')

head(pop_data)

 

idx <- which(pop_data[,'Firestation2']=='소계')

pop_cause <- pop_data[idx,]

 

pop_cause <- pop_cause[1:nrow(pop_cause),]

head(pop_cause)

ds <- data.frame(pop_num = as.numeric(pop_data$num),

                pop_cause$cause)

ds

colnames(ds)

 

library(ggplot2)

ggplot(ds,aes(x= pop_cause, y=pop_num, fill=colnames(ds))) +

  geom_bar(stat = "identity") +

  theme(axis.text.x=element_text(angle=45,colour="blue", size=10))

 

------------------------------------------------

 

<오류>
Don't know how to automatically pick scale for object of
type <data.frame>. Defaulting to continuous.
Error in `geom_bar()`:
! Problem while computing aesthetics.
ℹ Error occurred in the 1st layer.
Caused by error in `check_aesthetics()`:
! Aesthetics must be either length 1 or the same
  as the data (220)
✖ Fix the following mappings: `x` and `fill`
Run `rlang::last_error()` to see where the error occurred.
 
-------------------------------------------------
 
데이터 : https://data.seoul.go.kr/dataList/10949/S/2/datasetView.do
 
--------------------------------------------------
 
내용 : 
부주의에 의한 화재 유형 중 어떤 유형에 의해 가장 많은 화재가 발생하는 지 그래프를 만들려고 했는데
이런 오류가 떠서 질문 드립니다 ..ㅠㅠㅠㅠ 뭐가 문제일까요? ㅠㅠㅠㅠ
No. Subject Author Date
1014 생존분석에서 multivariate analysis에 대해 여쭙니다. [3] joon 2016.12.23
1013 R통계와 그래프 책을 보며 따라하는데... [2] 쿠싸길스패츌러 2016.12.23
1012 cox ph 모형 자동화 [1] hawk1227 2017.01.05
1011 교수님 문의드립니다~ [3] neurokim 2017.01.06
1010 matchit function 의 caliper 관련 질문입니다. 자라선생 2017.01.11
1009 생존나무분석에서 예측과 실제의 비교와 관하여 질문드립니다. (죄송하게도 또 글을 올립니다.) 자라선생 2017.01.11
1008 기본적인 data 파일 전환 방법 문의 [1] sunny112 2017.01.16
1007 구조방정식 강의 [1] file cardiomoon 2017.01.17
1006 1-생존함수 plot 문의드립니다. [3] file PipeDragoN 2017.01.18
1005 생존분석에서 missing value가 있는 경우 coxph 모델링은 어떻게 하는지요.. [2] PipeDragoN 2017.01.18
1004 1-생존함수에 관하여.. [1] PipeDragoN 2017.01.21
1003 교수님 문의드립니다~ [5] chamchi 2017.01.22
1002 생존분석에서의 interaction term 관련 여쭙습니다. Ridenc 2017.01.29
1001 로지스틱 회귀분석 질문 있습니다. [1] chamchi 2017.02.01
1000 Trend test [1] namuhanayeyo 2017.02.04
999 ANCOCA 질문드립니다. [1] BlcAng 2017.02.04
998 R notebook 에서 mytable 결과가 이상하게 나옵니다. [4] file Dilemma 2017.02.05
997 질문드립니다. [1] Dr.Han 2017.02.05
996 word cloud : pubmed error에 관하여 문의 드립니다. [3] file rhrroddl1 2017.02.06
995 web-r의 ggplot2를 사용해 보고 [2] 장미공원 2017.02.07