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
1154 산점도로 표현하고 싶은데요.. [2] file 난둥 2016.03.11
1153 Table 1 만들기 질문 [2] jaychoi 2016.03.13
1152 생존분석에서 설명변수 없이 생존곡선을 그리고 싶습니다. [4] sabqueen 2016.03.16
1151 그래프 그리기에 대한 질문입니다. [2] file 난둥 2016.03.18
1150 PSM와 c-statisticcs (AUC)에 관련해서 질문드립니다. 김정환 2016.03.22
1149 ANOVA, Kruskal-Wallis 검정 및 다중비교 [3] 소오름 2016.03.31
1148 자료전처리 문의드립니다 (두 명목변수를 조합해서 새 변수 생성) [2] 화모기 2016.03.31
1147 이 데이터의 비교를 하고 싶습니다. [3] file 소오름 2016.04.01
1146 메타분석에 대해 질문이 있습니다 [2] 카우보이 2016.04.01
1145 처음사용하는데 데이터 전처리가 어렵습니다. [1] namuhanayeyo 2016.04.02
1144 밑에서 질문 했던 자료입니다. [1] file 소오름 2016.04.03
1143 표만들기가 안되네요 ㅠㅠ [3] 피터팬79 2016.04.03
1142 자료 업뎃해서 다시 올립니다. [3] file 소오름 2016.04.03
1141 table 만들기에서, 나이 순으로 정렬시에 median 값과 범위를 지정할 수는 없는지요? [2] 혈액 2016.04.06
1140 R markdown 관련 질문드립니다. [1] Lloyd 2016.04.06
1139 ANOVA 사후분석은 어떻게 하나요? [2] drmin 2016.04.07
1138 web-r 에서 NRI, IDI 할수 있는지요,, [4] hawk1227 2016.04.07
1137 로지스틱 회귀 분석에서 반응(종속)변수에 결측치 [1] hawk1227 2016.04.07
1136 서버 접속과 문의 [2] file namuhanayeyo 2016.04.09
1135 파일 올려봅니다. [3] file namuhanayeyo 2016.04.11