DF_2 %>% filter(시도명) == "서울") %>%
코드를 이렇게 작성해봤는데 에러가 발생하더라고요
에러: `data` must be a data frame, or other object coercible by `fortify()`, not an S3 object with class uneval
Did you accidentally pass `aes()` to the `data` argument?
Run `rlang::last_error()` to see where the error occurred.
어떻게 해결 할 수 있나요!?
Comment 7
-
cardiomoon
2020.05.18 08:01
-
R입문기초
2020.05.18 16:12
> str(DF_3)List of 9$ data : tibble [35,530 x 22] (S3: tbl_df/tbl/data.frame)..$ V1 : int [1:35530] 2 3 6 8 16 17 23 29 33 37 .....$ 암호화YKIHO코드: chr [1:35530] "JDQ4MTg4MSM1MSMkMSMkMCMkODkkMzgxMzUxIzExIyQxIyQzIyQ3OSQ0NjEwMDIjNjEjJDEjJDQjJDgz" "JDQ4MTg4MSM1MSMkMSMkMCMkODkkMzgxMzUxIzExIyQxIyQzIyQ2MiQyNjE4MzIjNjEjJDEjJDQjJDgz" "JDQ4MTg4MSM1MSMkMSMkMCMkODkkMzgxMzUxIzExIyQxIyQzIyQ4OSQzNjEyMjIjODEjJDEjJDIjJDgz" "JDQ4MTg4MSM1MSMkMSMkMCMkODkkMzgxMzUxIzExIyQxIyQzIyQ2MiQ0NjEwMDIjNjEjJDEjJDAjJDgz" .....$ 요양기관명 : chr [1:35530] "강북삼성병원" "건국대학교병원" "경희대학교병원" "고려대학교의과대학부속구로병원" .....$ 종별코드 : int [1:35530] 1 1 1 1 1 1 1 1 1 1 .....$ 종별코드명 : chr [1:35530] "상급종합" "상급종합" "상급종합" "상급종합" .....$ 시도코드 : int [1:35530] 110000 110000 110000 110000 110000 110000 110000 110000 110000 110000 .....$ 시도명 : chr [1:35530] "서울" "서울" "서울" "서울" .....$ 시군구코드 : int [1:35530] 110016 110023 110007 110005 110001 110016 110001 110018 110008 110012 .....$ 시군구명 : chr [1:35530] "종로구" "광진구" "동대문구" "구로구" .....$ 읍면동 : chr [1:35530] NA NA NA NA .....$ 우편번호 : int [1:35530] 3181 5030 2447 8308 6351 3080 6273 5505 6973 2841 .....$ 주소 : chr [1:35530] "서울특별시 종로구 새문안로 29 (평동)" "서울특별시 광진구 능동로 120-1 (화양동)" "서울특별시 동대문구 경희대로 23 (회기동)" "서울특별시 구로구 구로동로 148 고려대부속구로병원 (구로동)" .....$ 전화번호 : chr [1:35530] "02-2001-2001" "1588-1533" "02-958-8114" "02-2626-1114" .....$ 병원URL : chr [1:35530] "http://www.kbsmc.co.kr" "http://www.kuh.ac.kr" "http://www.khuh.or.kr/" "http://guro.kumc.or.kr/main/index.do" .....$ 개설일자 : int [1:35530] 19790324 19821116 19711005 19830831 19940613 19810709 19830404 19890520 20041201 19740325 .....$ 의사총수 : int [1:35530] 380 417 452 531 1334 1526 612 1613 391 528 .....$ 인턴 의사수 : int [1:35530] 25 32 52 36 100 181 41 125 40 41 .....$ 레지던트 의사수: int [1:35530] 133 158 177 180 401 576 256 451 135 171 .....$ X좌표 : num [1:35530] 127 127 127 127 127 .....$ Y좌표 : num [1:35530] 37.6 37.5 37.6 37.5 37.5 .....$ doctor : chr [1:35530] "일반의 의사수" "일반의 의사수" "일반의 의사수" "일반의 의사수" .....$ count : int [1:35530] 5 1 5 1 23 17 2 23 1 5 ...$ layers :List of 1..$ :Classes 'LayerInstance', 'Layer', 'ggproto', 'gg' <ggproto object: Class LayerInstance, Layer, gg>aes_params: listcompute_aesthetics: functioncompute_geom_1: functioncompute_geom_2: functioncompute_position: functioncompute_statistic: functiondata: waiverdraw_geom: functionfinish_statistics: functiongeom: <ggproto object: Class GeomBar, GeomRect, Geom, gg>aesthetics: functiondefault_aes: unevaldraw_group: functiondraw_key: functiondraw_layer: functiondraw_panel: functionextra_params: na.rm orientationhandle_na: functionnon_missing_aes: xmin xmax ymin ymaxoptional_aes:parameters: functionrequired_aes: x ysetup_data: functionsetup_params: functionuse_defaults: functionsuper: <ggproto object: Class GeomRect, Geom, gg>geom_params: listinherit.aes: TRUElayer_data: functionmap_statistic: functionmapping: NULLposition: <ggproto object: Class PositionStack, Position, gg>compute_layer: functioncompute_panel: functionfill: FALSErequired_aes:reverse: FALSEsetup_data: functionsetup_params: functiontype: NULLvjust: 1super: <ggproto object: Class Position, gg>print: functionsetup_layer: functionshow.legend: NAstat: <ggproto object: Class StatIdentity, Stat, gg>aesthetics: functioncompute_group: functioncompute_layer: functioncompute_panel: functiondefault_aes: unevalextra_params: na.rmfinish_layer: functionnon_missing_aes:parameters: functionrequired_aes:retransform: TRUEsetup_data: functionsetup_params: functionsuper: <ggproto object: Class Stat, gg>stat_params: listsuper: <ggproto object: Class Layer, gg>$ scales :Classes 'ScalesList', 'ggproto', 'gg' <ggproto object: Class ScalesList, gg>add: functionclone: functionfind: functionget_scales: functionhas_scale: functioninput: functionn: functionnon_position_scales: functionscales: listsuper: <ggproto object: Class ScalesList, gg>$ mapping :List of 3..$ x : language ~시군구명.. ..- attr(*, ".Environment")=<environment: 0x000001ab6f1629d0>..$ y : language ~ifelse(doctor == "전문의 의사수", count, -count).. ..- attr(*, ".Environment")=<environment: 0x000001ab6f1629d0>..$ fill: language ~doctor.. ..- attr(*, ".Environment")=<environment: 0x000001ab6f1629d0>..- attr(*, "class")= chr "uneval"$ theme : list()$ coordinates:Classes 'CoordCartesian', 'Coord', 'ggproto', 'gg' <ggproto object: Class CoordCartesian, Coord, gg>aspect: functionbacktransform_range: functionclip: ondefault: TRUEdistance: functionexpand: TRUEis_free: functionis_linear: functionlabels: functionlimits: listmodify_scales: functionrange: functionrender_axis_h: functionrender_axis_v: functionrender_bg: functionrender_fg: functionsetup_data: functionsetup_layout: functionsetup_panel_guides: functionsetup_panel_params: functionsetup_params: functiontrain_panel_guides: functiontransform: functionsuper: <ggproto object: Class CoordCartesian, Coord, gg>$ facet :Classes 'FacetNull', 'Facet', 'ggproto', 'gg' <ggproto object: Class FacetNull, Facet, gg>compute_layout: functiondraw_back: functiondraw_front: functiondraw_labels: functiondraw_panels: functionfinish_data: functioninit_scales: functionmap_data: functionparams: listsetup_data: functionsetup_params: functionshrink: TRUEtrain_scales: functionvars: functionsuper: <ggproto object: Class FacetNull, Facet, gg>$ plot_env :<environment: 0x000001ab6f1629d0>$ labels :List of 4..$ title: chr "2020.03 병원 정보 서비스"..$ x : chr "시군구명"..$ y : chr "ifelse(doctor == \"전문의 의사수\", count, -count)"..$ fill : chr "doctor"- attr(*, "class")= chr [1:2] "gg" "ggplot"감사합니다. 위에를 해결하고 색상을 추가하려는데DF_3에러: Discrete value supplied to continuous scale 에러가 발생하네요!DF_3<-DF_2 %>% filter(시도명 == "서울") %>%ggplot(aes(x=시군구명, y=ifelse(doctor=='일반의 의사수', count, -count), fill=doctor)) +geom_bar(stat='identity', width=0.9,alpha=0.8)DF_3DF_3 <- DF_2 %>% filter(시도명 == "서울") %>%ggplot(aes(x=시군구명, y=ifelse(doctor=='일반의 의사수', count, -count), fill=doctor)) +geom_bar(stat='identity', width=0.9,alpha=0.8) +scale_x_continuous(name='시군구명') +scale_y_continuous(name='의사수', labels=c(50, 25, 0, 25, 50), limits=c(-500000,500000)) +scale_fill_manual(name='의사 종류', labels=c('일반의 의사수', '전문의 의사수'), values=c('tan3', 'maroon2')) +labs(title = '2020.03 병원 정보 서비스')str(DF_3)작성한 코드였습니다.어떻게 해당 오류를 해결할 수 있을까요? -
cardiomoon
2020.05.18 16:55
DF_3<-DF_2 %>% filter(시도명 == "서울")str(DF_3)해보셔요 -
R입문기초
2020.05.18 17:09
에러: `data` must be a data frame, or other object coercible by `fortify()`, not an S3 object with class unevalDid you accidentally pass `aes()` to the `data` argument?Run `rlang::last_error()` to see where the error occurred.가 발생하네요 -
cardiomoon
2020.05.18 18:01
data를 올려봐주시겠어요?
-
R입문기초
2020.05.18 18:03
여깄습니다!
-
cardiomoon
2020.05.18 19:41
require(tidyverse)df=read.csv("~/Downloads/hosp.csv",fileEncoding = "CP949")df1<-df %>%group_by(시도명)%>%summarize(일반의=sum(일반의.의사수),전문의=sum(전문의.의사수))df1 %>% pivot_longer(cols=일반의:전문의) -> df2ggplot(df2,aes(y=시도명,x=value,fill=name))+geom_col()+theme_bw(base_family="AppleGothic")
No. | Subject | Author | Date |
---|---|---|---|
814 | length 오류질문 [1] | 촙춉 | 2020.05.26 |
813 | 질문드립니다 | qubic | 2020.05.26 |
812 | heatmap [2] | zkbi | 2020.05.26 |
811 | 생존분석에 관해 질문드립니다. [3] | 투명한나비 | 2020.05.22 |
810 | ROC multiple predictor model에서 cutoff 질문드립니다 [1] | 박소현 | 2020.05.22 |
809 | 선생님, 안녕하십니까. ARCL 관련 질문 드립니다. | chrik | 2020.05.22 |
808 | diagnostic test [1] | 김날 | 2020.05.21 |
807 | P for trend [1] | Ryan | 2020.05.19 |
806 | PSM (propensity score matching) 결과 해석 관련 질문 드립니다. | nsstp | 2020.05.18 |
805 | ggpubr에 대해 질문드립니다. [2] | 송이싸리버섯 | 2020.05.18 |
» | ggplot 그래프 질문입니다. [7] | R입문기초 | 2020.05.17 |
803 | 정회원 기간 확인 [3] | 김날 | 2020.05.14 |
802 | PSM 에 대해서 문의 드립니다 [1] | jaljary | 2020.05.14 |
801 | 교수님 안녕하십니까? 논문 작성에 대해 질문이 있습니다. [1] | 디프 | 2020.05.14 |
800 | 정회원 web-R ver.4.0 survival graph [1] | 딸기공주 | 2020.05.13 |
799 | propensity score matching 에서 no units matched 라고 나옵니다. [2] | nsstp | 2020.05.13 |
798 | Plots of simple regression 다운로드 [2] | 김밥친구 | 2020.05.13 |
797 | 정회원 web-R ver.4.0 survival graph [2] | 딸기공주 | 2020.05.13 |
796 | cutoff 질문 | 루아 | 2020.05.12 |
795 | propensity score matching 질문드립니다. [5] | nsstp | 2020.05.12 |
DF_2 %>% filter(시도명) == "서울") 여기서 문제가 있네요. 괄호가 안 맞아요
DF_3<-DF_2 %>% filter(시도명 == "서울")
str(DF_3) 하시고 결과를 보여주셔요