https://rpubs.com/fumi/575348 https://sites.google.com/site/webtextofr/plot http://monge.tec.fukuoka-u.ac.jp/r_analysis/data_crosstable00.html
https://stackoverflow.com/questions/13994624/pie-chart-and-legend-are-overlapping
library(readr)
## Warning: package 'readr' was built under R version 3.6.2
getwd()
## [1] "C:/Users/721540/Documents/practice"
colors()
## [1] "white" "aliceblue" "antiquewhite"
## [4] "antiquewhite1" "antiquewhite2" "antiquewhite3"
## [7] "antiquewhite4" "aquamarine" "aquamarine1"
## [10] "aquamarine2" "aquamarine3" "aquamarine4"
## [13] "azure" "azure1" "azure2"
## [16] "azure3" "azure4" "beige"
## [19] "bisque" "bisque1" "bisque2"
## [22] "bisque3" "bisque4" "black"
## [25] "blanchedalmond" "blue" "blue1"
## [28] "blue2" "blue3" "blue4"
## [31] "blueviolet" "brown" "brown1"
## [34] "brown2" "brown3" "brown4"
## [37] "burlywood" "burlywood1" "burlywood2"
## [40] "burlywood3" "burlywood4" "cadetblue"
## [43] "cadetblue1" "cadetblue2" "cadetblue3"
## [46] "cadetblue4" "chartreuse" "chartreuse1"
## [49] "chartreuse2" "chartreuse3" "chartreuse4"
## [52] "chocolate" "chocolate1" "chocolate2"
## [55] "chocolate3" "chocolate4" "coral"
## [58] "coral1" "coral2" "coral3"
## [61] "coral4" "cornflowerblue" "cornsilk"
## [64] "cornsilk1" "cornsilk2" "cornsilk3"
## [67] "cornsilk4" "cyan" "cyan1"
## [70] "cyan2" "cyan3" "cyan4"
## [73] "darkblue" "darkcyan" "darkgoldenrod"
## [76] "darkgoldenrod1" "darkgoldenrod2" "darkgoldenrod3"
## [79] "darkgoldenrod4" "darkgray" "darkgreen"
## [82] "darkgrey" "darkkhaki" "darkmagenta"
## [85] "darkolivegreen" "darkolivegreen1" "darkolivegreen2"
## [88] "darkolivegreen3" "darkolivegreen4" "darkorange"
## [91] "darkorange1" "darkorange2" "darkorange3"
## [94] "darkorange4" "darkorchid" "darkorchid1"
## [97] "darkorchid2" "darkorchid3" "darkorchid4"
## [100] "darkred" "darksalmon" "darkseagreen"
## [103] "darkseagreen1" "darkseagreen2" "darkseagreen3"
## [106] "darkseagreen4" "darkslateblue" "darkslategray"
## [109] "darkslategray1" "darkslategray2" "darkslategray3"
## [112] "darkslategray4" "darkslategrey" "darkturquoise"
## [115] "darkviolet" "deeppink" "deeppink1"
## [118] "deeppink2" "deeppink3" "deeppink4"
## [121] "deepskyblue" "deepskyblue1" "deepskyblue2"
## [124] "deepskyblue3" "deepskyblue4" "dimgray"
## [127] "dimgrey" "dodgerblue" "dodgerblue1"
## [130] "dodgerblue2" "dodgerblue3" "dodgerblue4"
## [133] "firebrick" "firebrick1" "firebrick2"
## [136] "firebrick3" "firebrick4" "floralwhite"
## [139] "forestgreen" "gainsboro" "ghostwhite"
## [142] "gold" "gold1" "gold2"
## [145] "gold3" "gold4" "goldenrod"
## [148] "goldenrod1" "goldenrod2" "goldenrod3"
## [151] "goldenrod4" "gray" "gray0"
## [154] "gray1" "gray2" "gray3"
## [157] "gray4" "gray5" "gray6"
## [160] "gray7" "gray8" "gray9"
## [163] "gray10" "gray11" "gray12"
## [166] "gray13" "gray14" "gray15"
## [169] "gray16" "gray17" "gray18"
## [172] "gray19" "gray20" "gray21"
## [175] "gray22" "gray23" "gray24"
## [178] "gray25" "gray26" "gray27"
## [181] "gray28" "gray29" "gray30"
## [184] "gray31" "gray32" "gray33"
## [187] "gray34" "gray35" "gray36"
## [190] "gray37" "gray38" "gray39"
## [193] "gray40" "gray41" "gray42"
## [196] "gray43" "gray44" "gray45"
## [199] "gray46" "gray47" "gray48"
## [202] "gray49" "gray50" "gray51"
## [205] "gray52" "gray53" "gray54"
## [208] "gray55" "gray56" "gray57"
## [211] "gray58" "gray59" "gray60"
## [214] "gray61" "gray62" "gray63"
## [217] "gray64" "gray65" "gray66"
## [220] "gray67" "gray68" "gray69"
## [223] "gray70" "gray71" "gray72"
## [226] "gray73" "gray74" "gray75"
## [229] "gray76" "gray77" "gray78"
## [232] "gray79" "gray80" "gray81"
## [235] "gray82" "gray83" "gray84"
## [238] "gray85" "gray86" "gray87"
## [241] "gray88" "gray89" "gray90"
## [244] "gray91" "gray92" "gray93"
## [247] "gray94" "gray95" "gray96"
## [250] "gray97" "gray98" "gray99"
## [253] "gray100" "green" "green1"
## [256] "green2" "green3" "green4"
## [259] "greenyellow" "grey" "grey0"
## [262] "grey1" "grey2" "grey3"
## [265] "grey4" "grey5" "grey6"
## [268] "grey7" "grey8" "grey9"
## [271] "grey10" "grey11" "grey12"
## [274] "grey13" "grey14" "grey15"
## [277] "grey16" "grey17" "grey18"
## [280] "grey19" "grey20" "grey21"
## [283] "grey22" "grey23" "grey24"
## [286] "grey25" "grey26" "grey27"
## [289] "grey28" "grey29" "grey30"
## [292] "grey31" "grey32" "grey33"
## [295] "grey34" "grey35" "grey36"
## [298] "grey37" "grey38" "grey39"
## [301] "grey40" "grey41" "grey42"
## [304] "grey43" "grey44" "grey45"
## [307] "grey46" "grey47" "grey48"
## [310] "grey49" "grey50" "grey51"
## [313] "grey52" "grey53" "grey54"
## [316] "grey55" "grey56" "grey57"
## [319] "grey58" "grey59" "grey60"
## [322] "grey61" "grey62" "grey63"
## [325] "grey64" "grey65" "grey66"
## [328] "grey67" "grey68" "grey69"
## [331] "grey70" "grey71" "grey72"
## [334] "grey73" "grey74" "grey75"
## [337] "grey76" "grey77" "grey78"
## [340] "grey79" "grey80" "grey81"
## [343] "grey82" "grey83" "grey84"
## [346] "grey85" "grey86" "grey87"
## [349] "grey88" "grey89" "grey90"
## [352] "grey91" "grey92" "grey93"
## [355] "grey94" "grey95" "grey96"
## [358] "grey97" "grey98" "grey99"
## [361] "grey100" "honeydew" "honeydew1"
## [364] "honeydew2" "honeydew3" "honeydew4"
## [367] "hotpink" "hotpink1" "hotpink2"
## [370] "hotpink3" "hotpink4" "indianred"
## [373] "indianred1" "indianred2" "indianred3"
## [376] "indianred4" "ivory" "ivory1"
## [379] "ivory2" "ivory3" "ivory4"
## [382] "khaki" "khaki1" "khaki2"
## [385] "khaki3" "khaki4" "lavender"
## [388] "lavenderblush" "lavenderblush1" "lavenderblush2"
## [391] "lavenderblush3" "lavenderblush4" "lawngreen"
## [394] "lemonchiffon" "lemonchiffon1" "lemonchiffon2"
## [397] "lemonchiffon3" "lemonchiffon4" "lightblue"
## [400] "lightblue1" "lightblue2" "lightblue3"
## [403] "lightblue4" "lightcoral" "lightcyan"
## [406] "lightcyan1" "lightcyan2" "lightcyan3"
## [409] "lightcyan4" "lightgoldenrod" "lightgoldenrod1"
## [412] "lightgoldenrod2" "lightgoldenrod3" "lightgoldenrod4"
## [415] "lightgoldenrodyellow" "lightgray" "lightgreen"
## [418] "lightgrey" "lightpink" "lightpink1"
## [421] "lightpink2" "lightpink3" "lightpink4"
## [424] "lightsalmon" "lightsalmon1" "lightsalmon2"
## [427] "lightsalmon3" "lightsalmon4" "lightseagreen"
## [430] "lightskyblue" "lightskyblue1" "lightskyblue2"
## [433] "lightskyblue3" "lightskyblue4" "lightslateblue"
## [436] "lightslategray" "lightslategrey" "lightsteelblue"
## [439] "lightsteelblue1" "lightsteelblue2" "lightsteelblue3"
## [442] "lightsteelblue4" "lightyellow" "lightyellow1"
## [445] "lightyellow2" "lightyellow3" "lightyellow4"
## [448] "limegreen" "linen" "magenta"
## [451] "magenta1" "magenta2" "magenta3"
## [454] "magenta4" "maroon" "maroon1"
## [457] "maroon2" "maroon3" "maroon4"
## [460] "mediumaquamarine" "mediumblue" "mediumorchid"
## [463] "mediumorchid1" "mediumorchid2" "mediumorchid3"
## [466] "mediumorchid4" "mediumpurple" "mediumpurple1"
## [469] "mediumpurple2" "mediumpurple3" "mediumpurple4"
## [472] "mediumseagreen" "mediumslateblue" "mediumspringgreen"
## [475] "mediumturquoise" "mediumvioletred" "midnightblue"
## [478] "mintcream" "mistyrose" "mistyrose1"
## [481] "mistyrose2" "mistyrose3" "mistyrose4"
## [484] "moccasin" "navajowhite" "navajowhite1"
## [487] "navajowhite2" "navajowhite3" "navajowhite4"
## [490] "navy" "navyblue" "oldlace"
## [493] "olivedrab" "olivedrab1" "olivedrab2"
## [496] "olivedrab3" "olivedrab4" "orange"
## [499] "orange1" "orange2" "orange3"
## [502] "orange4" "orangered" "orangered1"
## [505] "orangered2" "orangered3" "orangered4"
## [508] "orchid" "orchid1" "orchid2"
## [511] "orchid3" "orchid4" "palegoldenrod"
## [514] "palegreen" "palegreen1" "palegreen2"
## [517] "palegreen3" "palegreen4" "paleturquoise"
## [520] "paleturquoise1" "paleturquoise2" "paleturquoise3"
## [523] "paleturquoise4" "palevioletred" "palevioletred1"
## [526] "palevioletred2" "palevioletred3" "palevioletred4"
## [529] "papayawhip" "peachpuff" "peachpuff1"
## [532] "peachpuff2" "peachpuff3" "peachpuff4"
## [535] "peru" "pink" "pink1"
## [538] "pink2" "pink3" "pink4"
## [541] "plum" "plum1" "plum2"
## [544] "plum3" "plum4" "powderblue"
## [547] "purple" "purple1" "purple2"
## [550] "purple3" "purple4" "red"
## [553] "red1" "red2" "red3"
## [556] "red4" "rosybrown" "rosybrown1"
## [559] "rosybrown2" "rosybrown3" "rosybrown4"
## [562] "royalblue" "royalblue1" "royalblue2"
## [565] "royalblue3" "royalblue4" "saddlebrown"
## [568] "salmon" "salmon1" "salmon2"
## [571] "salmon3" "salmon4" "sandybrown"
## [574] "seagreen" "seagreen1" "seagreen2"
## [577] "seagreen3" "seagreen4" "seashell"
## [580] "seashell1" "seashell2" "seashell3"
## [583] "seashell4" "sienna" "sienna1"
## [586] "sienna2" "sienna3" "sienna4"
## [589] "skyblue" "skyblue1" "skyblue2"
## [592] "skyblue3" "skyblue4" "slateblue"
## [595] "slateblue1" "slateblue2" "slateblue3"
## [598] "slateblue4" "slategray" "slategray1"
## [601] "slategray2" "slategray3" "slategray4"
## [604] "slategrey" "snow" "snow1"
## [607] "snow2" "snow3" "snow4"
## [610] "springgreen" "springgreen1" "springgreen2"
## [613] "springgreen3" "springgreen4" "steelblue"
## [616] "steelblue1" "steelblue2" "steelblue3"
## [619] "steelblue4" "tan" "tan1"
## [622] "tan2" "tan3" "tan4"
## [625] "thistle" "thistle1" "thistle2"
## [628] "thistle3" "thistle4" "tomato"
## [631] "tomato1" "tomato2" "tomato3"
## [634] "tomato4" "turquoise" "turquoise1"
## [637] "turquoise2" "turquoise3" "turquoise4"
## [640] "violet" "violetred" "violetred1"
## [643] "violetred2" "violetred3" "violetred4"
## [646] "wheat" "wheat1" "wheat2"
## [649] "wheat3" "wheat4" "whitesmoke"
## [652] "yellow" "yellow1" "yellow2"
## [655] "yellow3" "yellow4" "yellowgreen"
colors6 <- c("red","orange","yellow","lightgreen","green","skyblue")
colors23 <- c("red","antiquewhite","aquamarine","azure","bisque","blue",
"brown","burlywood","cadetblue","chartreuse","chocolate","coral",
"cyan","darkblue","darkgray","darkgreen","darkorange","darksalmon",
"darkslateblue","deeppink","gold","lavenderblush","lightblue")
# oumetest <- read.csv(file("oumetest.csv",encoding='utf8'), na = ".")
oumetest<- read_csv("oumetest.csv")
## Warning: Missing column names filled in: 'X12' [12]
## Warning: Duplicated column names deduplicated: 'no' => 'no_1' [9]
## Parsed with column specification:
## cols(
## .default = col_double(),
## 対応内容 = col_character(),
## 対応区分 = col_character(),
## 発生日 = col_character(),
## フラグ = col_character(),
## 備考 = col_character(),
## 住所 = col_character(),
## no_1 = col_character(),
## geocoding = col_character(),
## X12 = col_character(),
## 対処 = col_character(),
## 発生場所 = col_character(),
## 対策工法 = col_character(),
## 発生原因 = col_character()
## )
## See spec(...) for full column specifications.
income <- as.data.frame(oumetest)
#何故か家のpcでは次の文法でしか2バイト文字を読み込めなかったものが、こちらではエラーになる???なぜ?
#ancate <- read.csv(file("oumetest.csv",encoding='cp932'), na = ".")
#ancate <- read.csv("oumetest.csv", fileEncoding ='utf8', na = ".")#まちがい
ancate <- read.csv("oumetest.csv", fileEncoding ="UTF-8", na = ".")#まちがい
## Warning in read.table(file = file, header = header, sep = sep, quote = quote, :
## 入力コネクション 'oumetest.csv' に不正な入力がありました
## Warning in read.table(file = file, header = header, sep = sep, quote = quote, :
## incomplete final line found by readTableHeader on 'oumetest.csv'
income2 <- as.data.frame(ancate)
head(ancate)
## [1] X.
## <0 rows> (or 0-length row.names)
head(income2)
## [1] X.
## <0 rows> (or 0-length row.names)
ancate <- read.table("oumetest.csv", sep=",", skip=0, header=T, stringsAsFactors=F,fileEncoding="UTF-8")##まちがい?
## Warning in read.table("oumetest.csv", sep = ",", skip = 0, header = T,
## stringsAsFactors = F, : 入力コネクション 'oumetest.csv' に不正な入力がありました
## Warning in read.table("oumetest.csv", sep = ",", skip = 0, header = T,
## stringsAsFactors = F, : incomplete final line found by readTableHeader on
## 'oumetest.csv'
income2 <- as.data.frame(ancate)
head(ancate)
## [1] X.
## <0 rows> (or 0-length row.names)
head(income2)
## [1] X.
## <0 rows> (or 0-length row.names)
head(income)
## no
## 1 1
## 2 2
## 3 3
## 4 4
## 5 5
## 6 7
## 対応内容
## 1 マンホール番号123232354側(富岡3丁目1229側) 臭気 水路清掃 役所:平岡氏・松永氏立会い
## 2 マンホール番号183243402(新町1丁目24-26側) 枠周辺破損 補修工
## 3 マンホール番号183113440(師岡町2丁目354-8 岡野宅) 公共桝枠ズレ 補修工 役所:平岡氏立会い
## 4 マンホール番号203424413(末広町1丁目6側) 蓋間違い 蓋交換
## 5 マンホール番号182733401(日向和田1丁目113側) 蓋ボルトなし ボルト取付け
## 6 マンホール番号182933438他3箇所(西分町1丁目62側) 路面凹み 現場調査 役所:松永氏立会い
## 対応区分 発生月 発生日 フラグ 備考 住所
## 1 発生対応 (市民通報) 4 平成26年4月1日 ○ <NA> 富岡3-1229
## 2 予防保全(点検・調査) 4 平成26年4月1日 ○ <NA> 新町1-24-26
## 3 発生対応 (市民通報) 4 平成26年4月11日 ○ <NA> 師岡町2-354-8
## 4 予防保全(点検・調査) 4 平成26年4月11日 ○ <NA> 末広町1-6
## 5 予防保全(点検・調査) 4 平成26年4月11日 ○ <NA> 日向和田1-113
## 6 発生対応(その他) 4 平成26年4月17日 ○ <NA> 西分町1-62
## no_1 発生年度 geocoding X12 調査 工事
## 1 123232354 2014 青梅市富岡3-1229 臭気 雨水路清掃 0 0
## 2 183243402 2014 青梅市新町1-24-26 枠周辺破損 補修工 0 1
## 3 183113440 2014 青梅市師岡町2-354-8 公共桝枠ズレ 補修工 0 1
## 4 203424413 2014 青梅市末広町1-6 蓋間違い 蓋交換工 0 1
## 5 182733401 2014 青梅市日向和田1-113 蓋ボルトなし ボルト取付け工 0 1
## 6 182933438 2014 青梅市西分町1-62 路面凹み 現場調査 1 0
## 清掃 調査・工事 調査・清掃 対処 桝 人孔 副管 枠 蓋 弁 取付管 圧送管 路面 槽
## 1 1 0 0 清掃 0 0 0 0 0 0 0 0 0 0
## 2 0 0 0 工事 0 0 0 1 0 0 0 0 0 0
## 3 0 0 0 工事 1 0 0 1 0 0 0 0 0 0
## 4 0 0 0 工事 0 0 0 0 1 0 0 0 0 0
## 5 0 0 0 工事 0 0 0 0 1 0 1 0 0 0
## 6 0 0 0 調査 0 0 0 0 0 0 0 0 1 0
## 本管 雨水 宅地 発生場所 補修 除去 パッチング 木根除去 消毒 水替 蓋交換 充填
## 1 0 1 0 雨水施設 0 0 0 0 0 0 0 0
## 2 0 0 0 枠 1 0 0 0 0 0 0 0
## 3 0 0 0 桝 1 0 0 0 0 0 0 0
## 4 0 0 0 蓋 0 0 0 0 0 0 1 0
## 5 0 0 0 蓋 0 0 0 0 0 0 0 0
## 6 0 0 0 路面 0 0 0 0 0 0 0 0
## 砂補充 対策工法 油脂付着 臭気 つまり マンホール溢水 砂不足 木根侵入 ガツツキ
## 1 0 工事対象外他 0 1 0 0 0 0 0
## 2 0 補修 0 0 0 0 0 0 0
## 3 0 補修 0 0 0 0 0 0 0
## 4 0 蓋交換 0 0 0 0 0 0 0
## 5 0 工事対象外他 0 0 0 0 0 0 0
## 6 0 工事対象外他 0 0 0 0 0 0 0
## 段差 へこみ 破損 ズレ ウキ 陥没 発生原因
## 1 0 0 0 0 0 0 悪臭
## 2 0 0 1 0 0 0 破損
## 3 0 0 0 1 0 0 ズレ
## 4 0 0 0 0 0 0 その他
## 5 0 0 0 0 0 0 その他
## 6 0 1 0 0 0 0 凹み
dim(income)
## [1] 918 56
summary(income)
## no 対応内容 対応区分 発生月
## Min. : 1.0 Length:918 Length:918 Min. : 1.000
## 1st Qu.:230.8 Class :character Class :character 1st Qu.: 4.000
## Median :459.5 Mode :character Mode :character Median : 8.000
## Mean :459.5 Mean : 7.249
## 3rd Qu.:688.2 3rd Qu.:10.000
## Max. :917.0 Max. :12.000
## NA's :2 NA's :2
## 発生日 フラグ 備考 住所
## Length:918 Length:918 Length:918 Length:918
## Class :character Class :character Class :character Class :character
## Mode :character Mode :character Mode :character Mode :character
##
##
##
##
## no_1 発生年度 geocoding X12
## Length:918 Min. :2014 Length:918 Length:918
## Class :character 1st Qu.:2015 Class :character Class :character
## Mode :character Median :2017 Mode :character Mode :character
## Mean :2017
## 3rd Qu.:2018
## Max. :2019
## NA's :2
## 調査 工事 清掃 調査・工事
## Min. :0.0000 Min. :0.0000 Min. :0.00000 Min. :0.00000
## 1st Qu.:0.0000 1st Qu.:0.0000 1st Qu.:0.00000 1st Qu.:0.00000
## Median :0.0000 Median :0.0000 Median :0.00000 Median :0.00000
## Mean :0.2838 Mean :0.4367 Mean :0.04803 Mean :0.01638
## 3rd Qu.:1.0000 3rd Qu.:1.0000 3rd Qu.:0.00000 3rd Qu.:0.00000
## Max. :1.0000 Max. :1.0000 Max. :1.00000 Max. :1.00000
## NA's :2 NA's :2 NA's :2 NA's :2
## 調査・清掃 対処 桝 人孔
## Min. :0.000000 Length:918 Min. :0.000 Min. :0.0000
## 1st Qu.:0.000000 Class :character 1st Qu.:0.000 1st Qu.:0.0000
## Median :0.000000 Mode :character Median :0.000 Median :0.0000
## Mean :0.001092 Mean :0.191 Mean :0.1037
## 3rd Qu.:0.000000 3rd Qu.:0.000 3rd Qu.:0.0000
## Max. :1.000000 Max. :1.000 Max. :1.0000
## NA's :2 NA's :2 NA's :2
## 副管 枠 蓋 弁
## Min. :0.000000 Min. :0.0000 Min. :0.0000 Min. :0.00000
## 1st Qu.:0.000000 1st Qu.:0.0000 1st Qu.:0.0000 1st Qu.:0.00000
## Median :0.000000 Median :0.0000 Median :0.0000 Median :0.00000
## Mean :0.009825 Mean :0.2194 Mean :0.1321 Mean :0.02293
## 3rd Qu.:0.000000 3rd Qu.:0.0000 3rd Qu.:0.0000 3rd Qu.:0.00000
## Max. :1.000000 Max. :1.0000 Max. :1.0000 Max. :1.00000
## NA's :2 NA's :2 NA's :2 NA's :2
## 取付管 圧送管 路面 槽
## Min. :0.00000 Min. :0.000000 Min. :0.000 Min. :0.000000
## 1st Qu.:0.00000 1st Qu.:0.000000 1st Qu.:0.000 1st Qu.:0.000000
## Median :0.00000 Median :0.000000 Median :0.000 Median :0.000000
## Mean :0.08515 Mean :0.003275 Mean :0.131 Mean :0.002183
## 3rd Qu.:0.00000 3rd Qu.:0.000000 3rd Qu.:0.000 3rd Qu.:0.000000
## Max. :1.00000 Max. :1.000000 Max. :1.000 Max. :1.000000
## NA's :2 NA's :2 NA's :2 NA's :2
## 本管 雨水 宅地 発生場所
## Min. :0.00000 Min. :0.00000 Min. :0.00000 Length:918
## 1st Qu.:0.00000 1st Qu.:0.00000 1st Qu.:0.00000 Class :character
## Median :0.00000 Median :0.00000 Median :0.00000 Mode :character
## Mean :0.08188 Mean :0.01201 Mean :0.01965
## 3rd Qu.:0.00000 3rd Qu.:0.00000 3rd Qu.:0.00000
## Max. :1.00000 Max. :1.00000 Max. :1.00000
## NA's :2 NA's :2 NA's :2
## 補修 除去 パッチング 木根除去
## Min. :0.0000 Min. :0.00000 Min. :0.00000 Min. :0.00000
## 1st Qu.:0.0000 1st Qu.:0.00000 1st Qu.:0.00000 1st Qu.:0.00000
## Median :0.0000 Median :0.00000 Median :0.00000 Median :0.00000
## Mean :0.2107 Mean :0.08406 Mean :0.06441 Mean :0.02838
## 3rd Qu.:0.0000 3rd Qu.:0.00000 3rd Qu.:0.00000 3rd Qu.:0.00000
## Max. :1.0000 Max. :1.00000 Max. :1.00000 Max. :1.00000
## NA's :2 NA's :2 NA's :2 NA's :2
## 消毒 水替 蓋交換 充填
## Min. :0.00000 Min. :0.00000 Min. :0.00000 Min. :0.00000
## 1st Qu.:0.00000 1st Qu.:0.00000 1st Qu.:0.00000 1st Qu.:0.00000
## Median :0.00000 Median :0.00000 Median :0.00000 Median :0.00000
## Mean :0.01747 Mean :0.02293 Mean :0.03603 Mean :0.06769
## 3rd Qu.:0.00000 3rd Qu.:0.00000 3rd Qu.:0.00000 3rd Qu.:0.00000
## Max. :1.00000 Max. :1.00000 Max. :1.00000 Max. :1.00000
## NA's :2 NA's :2 NA's :2 NA's :2
## 砂補充 対策工法 油脂付着 臭気
## Min. :0.0000 Length:918 Min. : 0.00000 Min. :0.000000
## 1st Qu.:0.0000 Class :character 1st Qu.: 0.00000 1st Qu.:0.000000
## Median :0.0000 Mode :character Median : 0.00000 Median :0.000000
## Mean :0.0131 Mean : 0.07415 Mean :0.006543
## 3rd Qu.:0.0000 3rd Qu.: 0.00000 3rd Qu.:0.000000
## Max. :1.0000 Max. :34.00000 Max. :3.000000
## NA's :2 NA's :1 NA's :1
## つまり マンホール溢水 砂不足 木根侵入
## Min. : 0.00000 Min. : 0.0000 Min. : 0.00000 Min. : 0.00000
## 1st Qu.: 0.00000 1st Qu.: 0.0000 1st Qu.: 0.00000 1st Qu.: 0.00000
## Median : 0.00000 Median : 0.0000 Median : 0.00000 Median : 0.00000
## Mean : 0.09815 Mean : 0.0349 Mean : 0.02617 Mean : 0.05671
## 3rd Qu.: 0.00000 3rd Qu.: 0.0000 3rd Qu.: 0.00000 3rd Qu.: 0.00000
## Max. :45.00000 Max. :16.0000 Max. :12.00000 Max. :26.00000
## NA's :1 NA's :1 NA's :1 NA's :1
## ガツツキ 段差 へこみ 破損
## Min. : 0.0000 Min. : 0.0000 Min. : 0.0000 Min. : 0.0000
## 1st Qu.: 0.0000 1st Qu.: 0.0000 1st Qu.: 0.0000 1st Qu.: 0.0000
## Median : 0.0000 Median : 0.0000 Median : 0.0000 Median : 0.0000
## Mean : 0.1527 Mean : 0.1221 Mean : 0.1309 Mean : 0.3075
## 3rd Qu.: 0.0000 3rd Qu.: 0.0000 3rd Qu.: 0.0000 3rd Qu.: 0.0000
## Max. :70.0000 Max. :56.0000 Max. :60.0000 Max. :141.0000
## NA's :1 NA's :1 NA's :1 NA's :1
## ズレ ウキ 陥没 発生原因
## Min. : 0.0000 Min. :0.0000 Min. : 0.00000 Length:918
## 1st Qu.: 0.0000 1st Qu.:0.0000 1st Qu.: 0.00000 Class :character
## Median : 0.0000 Median :0.0000 Median : 0.00000 Mode :character
## Mean : 0.5719 Mean :0.0109 Mean : 0.05235
## 3rd Qu.: 0.0000 3rd Qu.:0.0000 3rd Qu.: 0.00000
## Max. :503.0000 Max. :5.0000 Max. :24.00000
## NA's :1 NA's :1
library(stargazer)
##
## Please cite as:
## Hlavac, Marek (2018). stargazer: Well-Formatted Regression and Summary Statistics Tables.
## R package version 5.2.2. https://CRAN.R-project.org/package=stargazer
#stargazer(as.data.frame(income),間違い
#```{r,results=“asis”} #strargazer(as.data.frame(oumetest), #type = “html”)
stargazer(as.data.frame(oumetest),
type = "html")
Statistic | N | Mean | St. Dev. | Min | Pctl(25) | Pctl(75) | Max |
no | 916 | 459.495 | 264.580 | 1.000 | 230.750 | 688.250 | 917.000 |
発生月 | 916 | 7.249 | 3.627 | 1.000 | 4.000 | 10.000 | 12.000 |
発生年度 | 916 | 2,016.605 | 1.651 | 2,014.000 | 2,015.000 | 2,018.000 | 2,019.000 |
調査 | 916 | 0.284 | 0.451 | 0.000 | 0.000 | 1.000 | 1.000 |
工事 | 916 | 0.437 | 0.496 | 0.000 | 0.000 | 1.000 | 1.000 |
清掃 | 916 | 0.048 | 0.214 | 0.000 | 0.000 | 0.000 | 1.000 |
調査・工事 | 916 | 0.016 | 0.127 | 0.000 | 0.000 | 0.000 | 1.000 |
調査・清掃 | 916 | 0.001 | 0.033 | 0.000 | 0.000 | 0.000 | 1.000 |
桝 | 916 | 0.191 | 0.393 | 0.000 | 0.000 | 0.000 | 1.000 |
人孔 | 916 | 0.104 | 0.305 | 0.000 | 0.000 | 0.000 | 1.000 |
副管 | 916 | 0.010 | 0.099 | 0.000 | 0.000 | 0.000 | 1.000 |
枠 | 916 | 0.219 | 0.414 | 0.000 | 0.000 | 0.000 | 1.000 |
蓋 | 916 | 0.132 | 0.339 | 0.000 | 0.000 | 0.000 | 1.000 |
弁 | 916 | 0.023 | 0.150 | 0.000 | 0.000 | 0.000 | 1.000 |
取付管 | 916 | 0.085 | 0.279 | 0.000 | 0.000 | 0.000 | 1.000 |
圧送管 | 916 | 0.003 | 0.057 | 0.000 | 0.000 | 0.000 | 1.000 |
路面 | 916 | 0.131 | 0.338 | 0.000 | 0.000 | 0.000 | 1.000 |
槽 | 916 | 0.002 | 0.047 | 0.000 | 0.000 | 0.000 | 1.000 |
本管 | 916 | 0.082 | 0.274 | 0.000 | 0.000 | 0.000 | 1.000 |
雨水 | 916 | 0.012 | 0.109 | 0.000 | 0.000 | 0.000 | 1.000 |
宅地 | 916 | 0.020 | 0.139 | 0.000 | 0.000 | 0.000 | 1.000 |
補修 | 916 | 0.211 | 0.408 | 0.000 | 0.000 | 0.000 | 1.000 |
除去 | 916 | 0.084 | 0.278 | 0.000 | 0.000 | 0.000 | 1.000 |
パッチング | 916 | 0.064 | 0.246 | 0.000 | 0.000 | 0.000 | 1.000 |
木根除去 | 916 | 0.028 | 0.166 | 0.000 | 0.000 | 0.000 | 1.000 |
消毒 | 916 | 0.017 | 0.131 | 0.000 | 0.000 | 0.000 | 1.000 |
水替 | 916 | 0.023 | 0.150 | 0.000 | 0.000 | 0.000 | 1.000 |
蓋交換 | 916 | 0.036 | 0.186 | 0.000 | 0.000 | 0.000 | 1.000 |
充填 | 916 | 0.068 | 0.251 | 0.000 | 0.000 | 0.000 | 1.000 |
砂補充 | 916 | 0.013 | 0.114 | 0.000 | 0.000 | 0.000 | 1.000 |
油脂付着 | 917 | 0.074 | 1.137 | 0.000 | 0.000 | 0.000 | 34.000 |
臭気 | 917 | 0.007 | 0.114 | 0.000 | 0.000 | 0.000 | 3.000 |
つまり | 917 | 0.098 | 1.500 | 0.000 | 0.000 | 0.000 | 45.000 |
マンホール溢水 | 917 | 0.035 | 0.544 | 0.000 | 0.000 | 0.000 | 16.000 |
砂不足 | 917 | 0.026 | 0.412 | 0.000 | 0.000 | 0.000 | 12.000 |
木根侵入 | 917 | 0.057 | 0.874 | 0.000 | 0.000 | 0.000 | 26.000 |
ガツツキ | 917 | 0.153 | 2.324 | 0.000 | 0.000 | 0.000 | 70.000 |
段差 | 917 | 0.122 | 1.863 | 0.000 | 0.000 | 0.000 | 56.000 |
へこみ | 917 | 0.131 | 1.995 | 0.000 | 0.000 | 0.000 | 60.000 |
破損 | 917 | 0.308 | 4.665 | 0.000 | 0.000 | 0.000 | 141.000 |
ズレ | 918 | 0.572 | 16.605 | 0 | 0 | 0 | 503 |
ウキ | 917 | 0.011 | 0.181 | 0.000 | 0.000 | 0.000 | 5.000 |
陥没 | 917 | 0.052 | 0.808 | 0.000 | 0.000 | 0.000 | 24.000 |
#library(xtable)
#print(xtable(income),type="html")
library(ggplot2) #ggplotパッケージをロード#日本語KUBUNだと作図されない
ggplot(income,aes(清掃))+
geom_histogram(aes(y = ..density..),
bins = 10,
colour = "gray",
fill = "blue")+
theme_classic()
## Warning: Removed 2 rows containing non-finite values (stat_bin).
#KK <- as.factor(income$清掃)
#KK
#library(ggplot2) #ggplotパッケージをロード#日本語KUBUNだと作図されない
#ggplot(income,aes(KK))+
#geom_histogram(aes(y = ..density..),
#bins = 10,
#colour = "gray",
#fill = "blue")+
# theme_classic()
colors <- c(1,2,3,4,5,6,7,8)
colors
## [1] 1 2 3 4 5 6 7 8
colors3 <- heat.colors(12)
colors4 <- rainbow(12)
library(RColorBrewer)
colors5<- brewer.pal(10, "Set1")
## Warning in brewer.pal(10, "Set1"): n too large, allowed maximum for palette Set1 is 9
## Returning the palette you asked for with that many colors
xx <- c("対応区分内訳")
table.q6 <- table(income$対応区分)
table.q6
##
## 緊急事態の待機・出動 発生対応 (市民通報)
## 37 285
## 発生対応(その他) 発生対応(道路等の管理者)
## 22 93
## 予防保全(その他) 予防保全(点検・調査)
## 216 262
par(xpd=TRUE)
pie(table.q6, col=rainbow(12),clockwise=TRUE)
legend("top", inset=c(0,-0.1),cex=1.5,legend = xx, fill=colors, bty="n")
上記グラフに%をいれる。
library(dplyr) library(ggplot2) library(scales)
df <- income group = c(“緊急事態の待機・出動”, “発生対応 (市民通報)”, “発生対応(その他)”, “発生対応(道路等の管理者),”予防保全(その他)“,”予防保全(点検・調査)") value = c(37, 285, 22, 93, 216,262)
df %>% ggplot(aes(x="“, y=value, fill=group)) + geom_col() + geom_text(aes(label = percent(value/100)), position = position_stack(vjust = 0.5)) + scale_fill_brewer(palette =”Blues“) + coord_polar(”y“) + theme_void() + labs(title =”TITLE“, fill =”LEGEND")
x <- c(“対応区分内訳”)
xx <- c(“緊急事態の待機・出動”, “発生対応 (市民通報)”, “発生対応(その他)”, “発生対応(道路等の管理者)”, “予防保全(その他)”, “予防保全(点検・調査)”)
colors <- colors6
xx <- c("緊急事態の待機・出動(4%)",
"発生対応 (市民通報)(31.1%)",
"発生対応(その他)(2.4%)",
"発生対応(道路等の管理者)(10.2%)",
"予防保全(その他)(23.6%)",
"予防保全(点検・調査)(28.6%)"
)
numb = c(37, 285, 22, 93, 216,262)
#par(mai = c(0,0,0,0))
par(mfrow=c(1,2))
layout(c(1,2),heights=c(1,2))
numb_labels <- round(numb/sum(numb) * 100, 1)
numb_labels <- paste(numb_labels, "%", sep=" ")
par(mai = c(0,0,0,0))
layout(c(1,2),heights=c(0.5,1))
plot.new()
legend("left", legend = xx, fill=colors, bty="o")
pie(numb, col=colors, labels=numb_labels, clockwise=TRUE)
par(mai = c(0,0,0,0))
layout(c(1,2),heights=c(0.3,1))
plot.new()
legend("bottom", legend = xx, fill=colors, bty="n")
pie(numb, col=colors, labels=numb_labels, clockwise=TRUE)
title("対応区分比率")
xx <- c("発生年度")
table.q6 <- table(income$発生年度)
table.q6
##
## 2014 2015 2016 2017 2018 2019
## 138 133 135 195 177 138
par(xpd=TRUE)
pie(table.q6, col=rainbow(12),clockwise=TRUE)
legend("top", inset=c(0,-0.1),cex=1.5,legend = xx, fill=colors, bty="n")
#カテゴリカル変数とカテゴリカル変数-クロス集計
発生月毎の対応区分 http://www.math.chuo-u.ac.jp/~sakaori/R/categorical.html
cross <- table(income\(発生月,income\)対応区分) prop.table(cross) prop.table(cross,1) prop.table(cross,2)
cross <- table(income$対応区分,income$発生月)
prop.table(cross)
##
## 1 2 3 4
## 緊急事態の待機・出動 0.000000000 0.003278689 0.001092896 0.001092896
## 発生対応 (市民通報) 0.019672131 0.017486339 0.022950820 0.028415301
## 発生対応(その他) 0.006557377 0.001092896 0.000000000 0.004371585
## 発生対応(道路等の管理者) 0.003278689 0.007650273 0.008743169 0.003278689
## 予防保全(その他) 0.014207650 0.018579235 0.015300546 0.017486339
## 予防保全(点検・調査) 0.030601093 0.019672131 0.014207650 0.014207650
##
## 5 6 7 8
## 緊急事態の待機・出動 0.001092896 0.000000000 0.000000000 0.001092896
## 発生対応 (市民通報) 0.025136612 0.028415301 0.014207650 0.022950820
## 発生対応(その他) 0.001092896 0.001092896 0.001092896 0.005464481
## 発生対応(道路等の管理者) 0.022950820 0.012021858 0.003278689 0.010928962
## 予防保全(その他) 0.018579235 0.018579235 0.013114754 0.029508197
## 予防保全(点検・調査) 0.009836066 0.028415301 0.010928962 0.004371585
##
## 9 10 11 12
## 緊急事態の待機・出動 0.002185792 0.026229508 0.000000000 0.004371585
## 発生対応 (市民通報) 0.024043716 0.040437158 0.040437158 0.027322404
## 発生対応(その他) 0.002185792 0.000000000 0.001092896 0.000000000
## 発生対応(道路等の管理者) 0.003278689 0.005464481 0.008743169 0.012021858
## 予防保全(その他) 0.031693989 0.029508197 0.010928962 0.018579235
## 予防保全(点検・調査) 0.003278689 0.030601093 0.027322404 0.092896175
https://stackoverflow.com/questions/13994624/pie-chart-and-legend-are-overlapping
#ここでは,t 関数で表のタテヨコをひっくり返して作っておく.
xx <- c("月別対応区分")
par(xpd=TRUE)
cross <- table(income$発生月,income$対応区分)
ptable <- cross
barplot(t(ptable), col=rainbow(12),legend = TRUE,clockwise=TRUE)
## Warning in plot.window(xlim, ylim, log = log, ...): "clockwise" はグラフィックス
## パラメータではありません
## Warning in axis(if (horiz) 2 else 1, at = at.l, labels = names.arg, lty =
## axis.lty, : "clockwise" はグラフィックスパラメータではありません
## Warning in title(main = main, sub = sub, xlab = xlab, ylab = ylab, ...):
## "clockwise" はグラフィックスパラメータではありません
## Warning in axis(if (horiz) 1 else 2, cex.axis = cex.axis, ...): "clockwise" はグ
## ラフィックスパラメータではありません
#legend("topleft", inset=c(0,-0.05),cex=1.0,legend = xx, fill=colors, bty="n")
title("月別対応区分度数")
逆転しているためx軸、y軸が逆転 https://stats.biopapyrus.jp/r/graph/barplot.html
xx <- c("月別対応区分")
cross <- table(income$発生月,income$対応区分)
ptable <- cross
par(xpd=TRUE)
barplot(t(ptable), col=rainbow(12),clockwise=TRUE,beside = TRUE)
## Warning in plot.window(xlim, ylim, log = log, ...): "clockwise" はグラフィックス
## パラメータではありません
## Warning in axis(if (horiz) 2 else 1, at = at.l, labels = names.arg, lty =
## axis.lty, : "clockwise" はグラフィックスパラメータではありません
## Warning in title(main = main, sub = sub, xlab = xlab, ylab = ylab, ...):
## "clockwise" はグラフィックスパラメータではありません
## Warning in axis(if (horiz) 1 else 2, cex.axis = cex.axis, ...): "clockwise" はグ
## ラフィックスパラメータではありません
title("月別対応区分度数")
#barplot(t(ptable), col=rainbow(12),beside = TRUE,legend = TRUE,xlab = “月”,ylab = “対応区分度数) barplot(t(ptable), col=rainbow(12),xlab =”月“,ylab =”対応区分度数)
par(xpd=TRUE)をいれるだけで上の凡例がきれいに見える
beside = TRUE にすると月別件数をならべて見える -reorderを使ってggplotの棒グラフの並び順を降順にする方法 http://tips-r.blogspot.com/2017/09/reorderggplot.html
月別順番入れ替え https://stackoverflow.com/questions/37480949/re-ordering-bars-in-rs-barplot/37481373
凡例なし
xx <- c("月別対応区分度数")
cross <- table(income$発生月,income$対応区分)
par(xpd=TRUE)
ptable <- cross
#ptable <- prop.table(cross)
barplot(t(ptable), col=rainbow(8),clockwise=TRUE,xlab = "対応月",ylab = "対応区分度数",beside = TRUE)
## Warning in plot.window(xlim, ylim, log = log, ...): "clockwise" はグラフィックス
## パラメータではありません
## Warning in axis(if (horiz) 2 else 1, at = at.l, labels = names.arg, lty =
## axis.lty, : "clockwise" はグラフィックスパラメータではありません
## Warning in title(main = main, sub = sub, xlab = xlab, ylab = ylab, ...):
## "clockwise" はグラフィックスパラメータではありません
## Warning in axis(if (horiz) 1 else 2, cex.axis = cex.axis, ...): "clockwise" はグ
## ラフィックスパラメータではありません
title("月別対応区分度数")
xx <- c("月別対応区分度数")
cross <- table(income$発生月,income$対応区分)
par(xpd=TRUE)
ptable <- cross
#ptable <- prop.table(cross)
barplot(t(ptable), col=rainbow(8),legend=TRUE,clockwise=TRUE,xlab = "対応月",ylab = "対応区分度数",beside = TRUE)
## Warning in plot.window(xlim, ylim, log = log, ...): "clockwise" はグラフィックス
## パラメータではありません
## Warning in axis(if (horiz) 2 else 1, at = at.l, labels = names.arg, lty =
## axis.lty, : "clockwise" はグラフィックスパラメータではありません
## Warning in title(main = main, sub = sub, xlab = xlab, ylab = ylab, ...):
## "clockwise" はグラフィックスパラメータではありません
## Warning in axis(if (horiz) 1 else 2, cex.axis = cex.axis, ...): "clockwise" はグ
## ラフィックスパラメータではありません
title("月別対応区分度数")
xx <- c("年度別対応区分度数")
cross <- table(income$発生年,income$対応区分)
par(xpd=TRUE)
ptable <- cross
#ptable <- prop.table(cross,2)
barplot(t(ptable), col=colors6,legend = TRUE,clockwise=TRUE,xlab = "年",ylab = "対応区分度数",beside = TRUE)
## Warning in plot.window(xlim, ylim, log = log, ...): "clockwise" はグラフィックス
## パラメータではありません
## Warning in axis(if (horiz) 2 else 1, at = at.l, labels = names.arg, lty =
## axis.lty, : "clockwise" はグラフィックスパラメータではありません
## Warning in title(main = main, sub = sub, xlab = xlab, ylab = ylab, ...):
## "clockwise" はグラフィックスパラメータではありません
## Warning in axis(if (horiz) 1 else 2, cex.axis = cex.axis, ...): "clockwise" はグ
## ラフィックスパラメータではありません
#legend("top", inset=c(-10,-0.1),cex=1.0, fill=rainbow(12), bty="n")
title("年度別対応区分度数")
xx <- c("年度別対応区分度数")
cross <- table(income$発生年,income$対応区分)
ptable <- cross
#ptable <- prop.table(cross,2)
barplot(t(ptable),col=colors6,clockwise=TRUE,xlab = "年",ylab = "対応区分度数",beside = TRUE)
## Warning in plot.window(xlim, ylim, log = log, ...): "clockwise" はグラフィックス
## パラメータではありません
## Warning in axis(if (horiz) 2 else 1, at = at.l, labels = names.arg, lty =
## axis.lty, : "clockwise" はグラフィックスパラメータではありません
## Warning in title(main = main, sub = sub, xlab = xlab, ylab = ylab, ...):
## "clockwise" はグラフィックスパラメータではありません
## Warning in axis(if (horiz) 1 else 2, cex.axis = cex.axis, ...): "clockwise" はグ
## ラフィックスパラメータではありません
par(xpd=TRUE)
title("年度別対応区分度数")
#legend("topleft", inset=c(-10,-0.1),cex=1.0, fill=colors, bty="n")
barplot(t(ptable),beside=TRUE,col=colors6,xlab = "年",ylab = "対応区分度数") # barの色だけ引き継ぐ、legendはinsetが入る
par(xpd=TRUE)
title("年度別対応区分度数")
barplot(t(ptable),beside=TRUE,col=cm.colors(8),xlab = “年”,ylab = “対応区分度数”,legend = TRUE) #
ptable <- prop.table(cross,2)
barplot(t(ptable),beside=TRUE,col=colors6,xlab = "年",ylab = "対応区分度数",legend = TRUE) # barの色だけ引き継ぐ、legendはinsetが入る
par(xpd=TRUE)
title("年度別対応区分度数")
凡例なし
barplot(t(ptable),beside=TRUE,col=colors6,xlab = "年",ylab = "対応区分度数") # barの色だけ引き継ぐ、legendはinsetが入る
par(xpd=TRUE)
title("年度別対応区分度数")
dat <- cbind(A=sample(10,3),B=sample(10,3),C=sample(10,3)) jpeg(“legend4.jpg”) par(mai=c(.8,.8,.8,1.2)) # 右端のスペースを開ける #par(xpd=FALSE) # グラフエリア外にプロットしない
,border=1:3,legend.text=colnames(ptable$対応区分)
xx <- c("発生源別月別対応区")
cross <- table(income$発生月,income$発生原因)
par(xpd=TRUE)
ptable <- cross
#ptable <- prop.table(cross,2)
barplot(t(ptable), col=rainbow(8),legend=TRUE,clockwise=TRUE,xlab = "対応月",ylab = "発生度数",beside = TRUE)
## Warning in plot.window(xlim, ylim, log = log, ...): "clockwise" はグラフィックス
## パラメータではありません
## Warning in axis(if (horiz) 2 else 1, at = at.l, labels = names.arg, lty =
## axis.lty, : "clockwise" はグラフィックスパラメータではありません
## Warning in title(main = main, sub = sub, xlab = xlab, ylab = ylab, ...):
## "clockwise" はグラフィックスパラメータではありません
## Warning in axis(if (horiz) 1 else 2, cex.axis = cex.axis, ...): "clockwise" はグ
## ラフィックスパラメータではありません
title("月別発生源別発生頻度")
xx <- c("発生源別月別対応区")
cross <- table(income$発生月,income$発生原因)
par(xpd=TRUE)
ptable <- cross
#ptable <- prop.table(cross,2)
barplot(t(ptable), col=rainbow(8),clockwise=TRUE,xlab = "対応月",ylab = "発生頻度",beside = TRUE)
## Warning in plot.window(xlim, ylim, log = log, ...): "clockwise" はグラフィックス
## パラメータではありません
## Warning in axis(if (horiz) 2 else 1, at = at.l, labels = names.arg, lty =
## axis.lty, : "clockwise" はグラフィックスパラメータではありません
## Warning in title(main = main, sub = sub, xlab = xlab, ylab = ylab, ...):
## "clockwise" はグラフィックスパラメータではありません
## Warning in axis(if (horiz) 1 else 2, cex.axis = cex.axis, ...): "clockwise" はグ
## ラフィックスパラメータではありません
title("月別発生源別発生頻度")
xx <- c("発生源別月別対応区")
cross <- table(income$発生月,income$発生原因)
par(xpd=TRUE)
ptable <- prop.table(cross,1)
barplot(t(ptable), col=colors23,clockwise=TRUE,xlab = "対応月",ylab = "発生頻度",beside = TRUE)
## Warning in plot.window(xlim, ylim, log = log, ...): "clockwise" はグラフィックス
## パラメータではありません
## Warning in axis(if (horiz) 2 else 1, at = at.l, labels = names.arg, lty =
## axis.lty, : "clockwise" はグラフィックスパラメータではありません
## Warning in title(main = main, sub = sub, xlab = xlab, ylab = ylab, ...):
## "clockwise" はグラフィックスパラメータではありません
## Warning in axis(if (horiz) 1 else 2, cex.axis = cex.axis, ...): "clockwise" はグ
## ラフィックスパラメータではありません
title("月別発生源別発生頻度")
xx <- c("発生源別月別対応区")
cross <- table(income$発生月,income$発生原因)
par(xpd=TRUE)
#ptable <- cross
ptable <- prop.table(cross,1)
barplot(t(ptable), col=colors23,clockwise=TRUE,xlab = "対応月",ylab = "発生頻度",beside = TRUE,legend=TRUE)
## Warning in plot.window(xlim, ylim, log = log, ...): "clockwise" はグラフィックス
## パラメータではありません
## Warning in axis(if (horiz) 2 else 1, at = at.l, labels = names.arg, lty =
## axis.lty, : "clockwise" はグラフィックスパラメータではありません
## Warning in title(main = main, sub = sub, xlab = xlab, ylab = ylab, ...):
## "clockwise" はグラフィックスパラメータではありません
## Warning in axis(if (horiz) 1 else 2, cex.axis = cex.axis, ...): "clockwise" はグ
## ラフィックスパラメータではありません
title("月別発生源別発生頻度")
ptable <- prop.table(cross) mosaicplot(ptable) legend(“top”, inset=c(0,-0.1),cex=1.5,legend = xx, fill=colors, bty=“n”)
ptable <- prop.table(cross,1) mosaicplot(ptable)
ptable <- prop.table(cross,2) mosaicplot(ptable)
x2 <- table(income\(対応区分, income\)発生日) x3 <- addmargins(x2) colnames(x3) [ncol(x3)] <- “合計” rownames(x3) [nrow(x3)] <- “合計” # と記述し行columnと列rowの文字を書き換える. x3
https://markezine.jp/article/detail/20790
library(polycor) polychor(income\(対応区分, income\)発生日,std.err=TRUE)
polychor(income\(対応区分, income\)geocoding, std.err=TRUE)
library(polycor)
## Warning: package 'polycor' was built under R version 3.6.2
polychor(income\(対応区分, income\)清掃, std.err=TRUE)
bfi <- income bfi <- bfi[-1][-3:-5][-6:-10][-13:-47] # 不要なカラム名を取り除く bfi2 <- income[2:14] bfi2 <- bfi2[-8:-10] bfi2 <- bfi2[-4:-5] bfi2 <- bfi2[-5] bfi2 dim(bfi2) #polychor(bfi2, polycor=TRUE)
#polychor(bfi2, std.err=TRUE)
polychor(bfi)
ggplot(income, aes(as.factor(清掃))) +
geom_bar() +
theme_bw()