{"id":9784,"date":"2017-05-18T15:00:52","date_gmt":"2017-05-18T06:00:52","guid":{"rendered":"http:\/\/sitest.jp\/blog\/?p=9784"},"modified":"2017-05-18T01:43:21","modified_gmt":"2017-05-17T16:43:21","slug":"%e7%9f%a5%e3%81%a3%e3%81%a6%e3%81%8a%e3%81%84%e3%81%a6%e6%90%8d%e3%81%af%e3%81%aa%e3%81%84%ef%bc%81-r-%e8%a8%80%e8%aa%9e%e3%81%ae%e3%81%8a%e3%81%99%e3%81%99%e3%82%81%e3%83%91%e3%83%83%e3%82%b1","status":"publish","type":"post","link":"https:\/\/sitest.jp\/blog\/?p=9784","title":{"rendered":"\u77e5\u3063\u3066\u304a\u3044\u3066\u640d\u306f\u306a\u3044\uff01 R \u8a00\u8a9e\u306e\u304a\u3059\u3059\u3081\u30d1\u30c3\u30b1\u30fc\u30b810\u9078"},"content":{"rendered":"<p>\u307f\u306a\u3055\u3093\u306f R \u8a00\u8a9e\u306e\u30d1\u30c3\u30b1\u30fc\u30b8\u3067\u3069\u306e\u3088\u3046\u306a\u3082\u306e\u3092\u4f7f\u7528\u3055\u308c\u3066\u3044\u307e\u3059\u304b\uff1f<\/p>\n<p>R \u3067\u306f CRAN \u3092\u901a\u3057\u3066\u69d8\u3005\u306a\u30d1\u30c3\u30b1\u30fc\u30b8\u304c\u516c\u958b\u30fb\u63d0\u4f9b\u3055\u308c\u3066\u3044\u307e\u3059\u3002<br \/>\n\u4eca\u56de\u306f R \u3067\u7d71\u8a08\u89e3\u6790\u3092\u3059\u308b\u305f\u3081\u306b\u4fbf\u5229\u306a\u304a\u3059\u3059\u3081\u30d1\u30c3\u30b1\u30fc\u30b8\u3092\u3054\u7d39\u4ecb\u3057\u307e\u3059\uff01<\/p>\n<p><!--more--><\/p>\n<div class=\"frame_headding\">\n<h3 style=\"text-align: left;\">\u305d\u3082\u305d\u3082\u30d1\u30c3\u30b1\u30fc\u30b8\u3068\u306f\uff1f<\/h3>\n<\/div>\n<p>\u30d1\u30c3\u30b1\u30fc\u30b8\u3068\u306f\u3001\u30e6\u30fc\u30b6\u304c\u4f5c\u6210\u3057\u305f R \u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u3084\u95a2\u6570\u7fa4\u3001\u30e9\u30a4\u30d6\u30e9\u30ea\u306a\u3069\u3092\u6307\u3057\u307e\u3059\u3002<br \/>\n<a rel=\"nofollow\" href=\"https:\/\/cran.r-project.org\/\" target=\"_blank\">CRAN\uff08Comprehensive R Archive Network\uff09<\/a> \u306f\u3001 R \u672c\u4f53\u3084\u5404\u7a2e\u30d1\u30c3\u30b1\u30fc\u30b8\u3092\u30c0\u30a6\u30f3\u30ed\u30fc\u30c9\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u308bWeb\u30b5\u30a4\u30c8\u3067\u3001\u4e16\u754c\u4e2d\u306b\u30df\u30e9\u30fc\u30b5\u30a4\u30c8\u304c\u5b58\u5728\u3057\u3066\u3044\u307e\u3059\u3002<br \/>\n\u65e5\u672c\u306b\u3082<a target=\"_blank\" rel=\"nofollow\" href=\"https:\/\/cran.ism.ac.jp\/\">\u7d71\u8a08\u6570\u7406\u7814\u7a76\u6240\u30df\u30e9\u30fc<\/a>\u3084<a target=\"_blank\" rel=\"nofollow\" href=\"ftp:\/\/ftp.u-aizu.ac.jp\/pub\/lang\/R\/CRAN\">\u4f1a\u6d25\u5927\u5b66\u30df\u30e9\u30fc<\/a>\u306a\u3069\u306e\u30b5\u30a4\u30c8\u304c\u5b58\u5728\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n<div class=\"frame_headding\">\n<h3 style=\"text-align: left;\">\u304a\u3059\u3059\u3081\u30d1\u30c3\u30b1\u30fc\u30b810\u9078<\/h3>\n<\/div>\n<h4 style=\"border-bottom: solid 4px #73bc9b; margin: 30px 0;\">1. \u30c7\u30fc\u30bf\u30d5\u30ec\u30fc\u30e0\u64cd\u4f5c: dplyr <\/h4>\n<p><a target=\"_blank\" rel=\"nofollow\" href=\"https:\/\/github.com\/tidyverse\/dplyr\">dplyr<\/a> \u306f\u30c7\u30fc\u30bf\u30d5\u30ec\u30fc\u30e0\u64cd\u4f5c\u306b\u7279\u5316\u3057\u305f plyr \u306e\u6d3e\u751f\u30d1\u30c3\u30b1\u30fc\u30b8\u3067\u3059\u3002<br \/>\n\u3053\u306e\u30d1\u30c3\u30b1\u30fc\u30b8\u306f C++ \u3067\u4f5c\u6210\u3055\u308c\u3066\u3044\u308b\u305f\u3081\u3001 R \u3067\u540c\u3058\u51e6\u7406\u3092\u884c\u3046\u3088\u308a\u3082\u9ad8\u901f\u306b\u52d5\u4f5c\u3057\u307e\u3059\u3002<br \/>\n\u7d5e\u308a\u8fbc\u307f\u3084\u96c6\u8a08\u3001\u30b0\u30eb\u30fc\u30d4\u30f3\u30b0\u3001\u30bd\u30fc\u30c8\u306a\u3069\u30c7\u30fc\u30bf\u30d5\u30ec\u30fc\u30e0\u306e\u64cd\u4f5c\u3092\u3059\u308b\u5834\u5408\u306b\u306f\u3082\u3063\u3066\u3053\u3044\u306e\u30d1\u30c3\u30b1\u30fc\u30b8\u3067\u3059\u3002<\/p>\n<pre><code class=\"r\">library(dplyr)\n\nsex <- c(\"F\",\"F\",\"M\",\"M\",\"M\")\nage <- c(20, 28, 40, 34, 50)\nheight <- c(158,162,177,173,166)\nweight <- c(51,55,72,57,64)\nx <- data.frame(SEX=sex, AGE=age, HEIGHT=height, WEIGHT=weight)\n\n# filter\ndplyr::filter(x, (SEX == \"F\"))\n\n# grouping\ndplyr::group_by(x, SEX)\n\n# sort\ndplyr::arrange(x, desc(AGE))\n<\/code><\/pre>\n<h4 style=\"border-bottom: solid 4px #73bc9b; margin: 30px 0;\">2. \u30c7\u30fc\u30bf\u306e\u53ef\u8996\u5316: ggplot2 <\/h4>\n<p>R \u306b\u306f\u30c7\u30d5\u30a9\u30eb\u30c8\u3067\u4f5c\u56f3\u95a2\u6570\u3067\u3042\u308b plot \u304c\u5099\u308f\u3063\u3066\u3044\u307e\u3059\u304c\u3001<br \/>\n <a target=\"_blank\" rel=\"nofollow\" href=\"https:\/\/github.com\/tidyverse\/ggplot2\">ggplot2<\/a> \u3067\u306f\u3088\u308a\u4fbf\u5229\u306b\u304d\u308c\u3044\u306a\u30b0\u30e9\u30d5\u3092\u63cf\u753b\u3059\u308b\u3053\u3068\u304c\u51fa\u6765\u307e\u3059\u3002<\/p>\n<p>\u30c7\u30d5\u30a9\u30eb\u30c8\u306e plot \u95a2\u6570\u3068 ggplot2 \u95a2\u6570\u306e\u30b0\u30e9\u30d5\u3092\u6bd4\u3079\u3066\u307f\u307e\u3057\u3087\u3046\u3002<\/p>\n<p>\u3053\u3061\u3089\u304c plot \u95a2\u6570\u3067\u4f5c\u6210\u3057\u305f\u30b0\u30e9\u30d5\u3002<br \/>\n<!-- img plot --><br \/>\n<a target=\"_blank\" href=\"https:\/\/storage.googleapis.com\/sitest-wp\/blog\/wp-content\/uploads\/2017\/04\/iris_plot.png\"><img loading=\"lazy\" src=\"https:\/\/storage.googleapis.com\/sitest-wp\/blog\/wp-content\/uploads\/2017\/04\/iris_plot.png\" alt=\"\" width=\"614\" height=\"406\" class=\"alignnone size-full wp-image-9837\" \/><\/a><\/p>\n<p>\u3053\u3061\u3089\u304c ggplot2 \u95a2\u6570\u3067\u4f5c\u6210\u3057\u305f\u30b0\u30e9\u30d5\u3002<br \/>\n<!-- img ggplot2 --><br \/>\n<a target=\"_blank\" href=\"https:\/\/storage.googleapis.com\/sitest-wp\/blog\/wp-content\/uploads\/2017\/04\/iris_ggplot.png\"><img loading=\"lazy\" src=\"https:\/\/storage.googleapis.com\/sitest-wp\/blog\/wp-content\/uploads\/2017\/04\/iris_ggplot.png\" alt=\"\" width=\"614\" height=\"406\" class=\"alignnone size-full wp-image-9838\" \/><\/a><\/p>\n<pre><code class=\"r\">library(ggplot2)\n\n# plot\nplot(iris$Sepal.Length, iris$Sepal.Width)\n\n# ggplot2\ngp = ggplot(iris, aes(x = Sepal.Length, y = Sepal.Width, colour=Species))\ngp = gp + geom_point(size = 3, alpha = 0.7)\nprint(gp)\n<\/code><\/pre>\n<p>ggplot2 \u95a2\u6570\u3092\u4f7f\u3046\u3053\u3068\u3067\u540c\u3058\u30c7\u30fc\u30bf\u63cf\u753b\u3067\u3082\u3001\u3068\u3066\u3082\u7dba\u9e97\u306b\u30b0\u30e9\u30d5\u3092\u66f8\u304f\u3053\u3068\u304c\u3067\u304d\u3001\u6563\u5e03\u56f3\u3060\u3051\u3067\u306a\u304f\u6298\u308c\u7dda\u30b0\u30e9\u30d5\u3084\u30d2\u30b9\u30c8\u30b0\u30e9\u30e0\u3001\u30d2\u30fc\u30c8\u30de\u30c3\u30d7\u3084\u56de\u5e30\u66f2\u7dda\u306a\u3069\u5927\u4f53\u306e\u30b0\u30e9\u30d5\u306f\u4f5c\u6210\u3067\u304d\u307e\u3059\u3002<\/p>\n<h4 style=\"border-bottom: solid 4px #73bc9b; margin: 30px 0;\">3. \u30d1\u30a4\u30d7\u51e6\u7406: magrittr <\/h4>\n<p>R \u3067\u3082\u30d1\u30a4\u30d7\u51e6\u7406\u3092\u7528\u3044\u308b\u3053\u3068\u3067\u3001\u30b3\u30fc\u30c9\u306e\u53ef\u8aad\u6027\u3092\u9ad8\u3081\u308b\u3053\u3068\u304c\u51fa\u6765\u307e\u3059\u3002<br \/>\n<a target=\"_blank\" rel=\"nofollow\" href=\"https:\/\/github.com\/tidyverse\/magrittr\">magritter<\/a> \u3067\u306f R \u3067\u30d1\u30a4\u30d7\u51e6\u7406\u3092\u5b9f\u73fe\u3059\u308b\u3053\u3068\u304c\u51fa\u6765\u307e\u3059\u3002<br \/>\n\u3053\u306e\u30d1\u30c3\u30b1\u30fc\u30b8\u306f dplyr \u306a\u3069\u6570\u591a\u304f\u306e\u30d1\u30c3\u30b1\u30fc\u30b8\u3092\u652f\u3048\u3066\u3044\u307e\u3059\u3002<\/p>\n<pre><code class=\"r\">library(magrittr)\n\nx %>% f # f(x)\nx %>% f(y) # f(x, y)\nx %>% f %>% g %>% h # h(g(f(x)))\nx %>% f(y, .) # f(y, x)\nx %>% f(y, z = .) # f(y, z = x)\n\nlibrary(dplyr)\niris %>%\n  dplyr::filter(Species == \"setosa\")\n<\/code><\/pre>\n<h4 style=\"border-bottom: solid 4px #73bc9b; margin: 30px 0;\">4. \u30ec\u30dd\u30fc\u30c6\u30a3\u30f3\u30b0: rmarkdown <\/h4>\n<p><a target=\"_blank\" rel=\"nofollow\" href=\"https:\/\/github.com\/rstudio\/rmarkdown\">rmarkdown<\/a> \u306f\u3001 Markdown\u5f62\u5f0f\u3067\u4f5c\u6210\u3057\u305f\u30ec\u30dd\u30fc\u30c8\u306b R \u3067\u4f5c\u6210\u3057\u305f\u30c7\u30fc\u30bf\u3084\u30b0\u30e9\u30d5\u3092\u5f53\u3066\u306f\u3081\u8fbc\u307f\u3001 PDF \u3084 Wor \u3001 HTML \u306a\u3069\u306e\u30d5\u30a9\u30fc\u30de\u30c3\u30c8\u3078\u51fa\u529b\u3059\u308b\u3053\u3068\u304c\u51fa\u6765\u308b\u30d1\u30c3\u30b1\u30fc\u30b8\u3067\u3059\u3002<br \/>\nrmarkdown \u3092\u4f7f\u7528\u3059\u308b\u305f\u3081\u306b\u306f\u5225\u9014 <a target=\"_blank\" rel=\"nofollow\" href=\"http:\/\/pandoc.org\/index.html\">pandoc<\/a> \u3068\u3044\u3046\u30c4\u30fc\u30eb\u3082\u5fc5\u8981\u3068\u306a\u308a\u307e\u3059\u3002<br \/>\n\u30b5\u30a4\u30c8\u306b\u306f\u30d7\u30e9\u30c3\u30c8\u30d5\u30a9\u30fc\u30e0\u5225\u306b\u30a4\u30f3\u30b9\u30c8\u30fc\u30e9\u304c\u914d\u5e03\u3055\u308c\u3066\u3044\u307e\u3059\u306e\u3067\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3057\u307e\u3057\u3087\u3046\u3002<br \/>\nRStudio \u3092\u4f7f\u7528\u3057\u3066\u30b5\u30f3\u30d7\u30eb\u306e HTML \u30ec\u30dd\u30fc\u30c8\u3092\u4f5c\u6210\u3057\u3066\u307f\u307e\u3057\u305f\u3002<\/p>\n<p><a target=\"_blank\" href=\"https:\/\/storage.googleapis.com\/sitest-wp\/blog\/wp-content\/uploads\/2017\/04\/rmarkdonw.png\"><img loading=\"lazy\" src=\"https:\/\/storage.googleapis.com\/sitest-wp\/blog\/wp-content\/uploads\/2017\/04\/rmarkdonw.png\" alt=\"\" width=\"604\" height=\"531\" class=\"alignnone size-large wp-image-9918\" \/><\/a><\/p>\n<p>\u4e88\u3081\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u3092\u4f5c\u6210\u3057\u3066\u304a\u304f\u3053\u3068\u3067\u3001\u9031\u6b21\u3084\u6708\u6b21\u306e\u30ec\u30dd\u30fc\u30c6\u30a3\u30f3\u30b0\u304c\u3068\u3066\u3082\u7c21\u5358\u306b\u4f5c\u6210\u3067\u304d\u307e\u3059\u306e\u3067\u305c\u3072\u3054\u6d3b\u7528\u4e0b\u3055\u3044\u3002<\/p>\n<h4 style=\"border-bottom: solid 4px #73bc9b; margin: 30px 0;\">5. \u6587\u5b57\u5217\u64cd\u4f5c: stringr <\/h4>\n<p><a target=\"_blank\" rel=\"nofollow\" href=\"https:\/\/github.com\/tidyverse\/stringr\">stringr<\/a> \u306f\u3001 R \u3067\u306e\u6587\u5b57\u5217\u64cd\u4f5c\u3092\u3057\u3084\u3059\u304f\u306a\u308b\u30d1\u30c3\u30b1\u30fc\u30b8\u3067\u3059\u3002<br \/>\n\u6b63\u898f\u8868\u73fe\u306b\u3088\u308b\u30d1\u30bf\u30fc\u30f3\u30de\u30c3\u30c1\u3084\u5927\u6587\u5b57\u5c0f\u6587\u5b57\u5909\u63db\u306a\u3069\u3082\u5099\u3048\u3066\u3044\u307e\u3059\u3002<\/p>\n<pre><code class=\"r\">library(stringr)\n\nx <- c(\"Lorem\",\"ipsum\",\"dolor\",\"sit\",\"amet\",\"consectetur\",\"adipiscing\",\"elit\")\n# basic\nstr_length(x) # [1]  5  5  5  3  4 11 10  4\nstr_c(x, collapse = \" \") # [1] \"Lorem ipsum dolor sit amet consectetur adipiscing elit\"\n\n# pattern match\nstr_count(x, \"o\") # [1] 1 0 2 0 0 1 0 0\nstr_detect(x, \"o\") # [1]  TRUE FALSE  TRUE FALSE FALSE  TRUE FALSE FALSE\n\n# fotmat\nstr_to_title(x)\n# [1] \"Lorem\"       \"Ipsum\"       \"Dolor\"       \"Sit\"         \"Amet\"       \n# [6] \"Consectetur\" \"Adipiscing\"  \"Elit\"\n<\/code><\/pre>\n<h4 style=\"border-bottom: solid 4px #73bc9b; margin: 30px 0;\">6. \u65e5\u4ed8\u64cd\u4f5c: lubridate <\/h4>\n<p><a target=\"_blank\" rel=\"nofollow\" href=\"https:\/\/github.com\/hadley\/lubridate\">lubridate<\/a> \u306f\u3001 R \u3067\u306e\u65e5\u4ed8\u64cd\u4f5c\u3092\u4fbf\u5229\u306b\u3059\u308b\u30d1\u30c3\u30b1\u30fc\u30b8\u3067\u3059\u3002<br \/>\n\u6a19\u6e96\u3067\u4f7f\u7528\u3067\u304d\u308b as.Date \u3068 lubridate \u3092\u4f7f\u3063\u3066\u6bd4\u8f03\u3057\u3066\u307f\u307e\u3057\u3087\u3046\u3002<\/p>\n<pre><code class=\"r\">library(lubridate)\n\nas.Date(\"2017-04-01\")\nas.Date(\"04-01-2017\", format = \"%m-%d-%Y\")\n\nymd(\"2017-04-01\")\nmdy(\"04-01-2017\")\n\nx <- c(\n  \"second chapter due on 2013, august, 24\",\n  \"first chapter submitted on 2013, 08, 18\",\n  \"2013 aug 23\")\nymd(x, locale = \"C\", tz = \"Asia\/Tokyo\")\n# [1] \"2013-08-24 JST\" \"2013-08-18 JST\" \"2013-08-23 JST\"\n<\/code><\/pre>\n<p>\u307b\u304b\u306b\u3082\u672c\u65e5\u306e\u65e5\u4ed8\u3092\u51fa\u3059 today \u3084\u3046\u308b\u3046\u5e74\u5224\u5b9a\u306e leap_year \u306a\u3069\u4fbf\u5229\u306a\u95a2\u6570\u304c\u63c3\u3063\u3066\u3044\u307e\u3059\u3002<\/p>\n<h4 style=\"border-bottom: solid 4px #73bc9b; margin: 30px 0;\">7. MySQL\u304b\u3089\u30c7\u30fc\u30bf\u53d6\u5f97: RMySQL <\/h4>\n<p><a targetl=\"_blank\" rel=\"nofollow\" href=\"https:\/\/github.com\/rstats-db\/RMySQL\">RMySQL<\/a> \u306f\u3001 R \u304b\u3089 MySQL \u306b\u63a5\u7d9a\u3059\u308b\u305f\u3081\u306e\u30c9\u30e9\u30a4\u30d0\u30d1\u30c3\u30b1\u30fc\u30b8\u3067\u3059\u3002<br \/>\nRMySQL \u3092\u901a\u3057\u3066\u3001 MySQL \u306b\u4fdd\u5b58\u3055\u308c\u3066\u3044\u308b\u30c7\u30fc\u30bf\u304b\u3089 R \u3067\u30c7\u30fc\u30bf\u89e3\u6790\u3092\u884c\u3063\u305f\u308a\u3001\u89e3\u6790\u7d50\u679c\u3092 MySQL \u306b\u4fdd\u5b58\u3059\u308b\u6642\u306b\u4f7f\u7528\u3057\u307e\u3059\u3002<\/p>\n<p>\u4f8b\u3048\u3070\u3001 WordPress \u306e\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u304b\u3089\u5168\u3066\u306e\u8a18\u4e8b\u60c5\u5831\u3092\u53d6\u5f97\u3057 dplyr \u3067\u516c\u958b\u72b6\u614b\u306e\u8a18\u4e8b\u306e\u307f\u306b\u30d5\u30a3\u30eb\u30bf\u30ea\u30f3\u30b0\u3057\u3066\u307f\u307e\u3059\u3002<\/p>\n<pre><code class=\"r\">library(DBI)\nlibrary(RMySQL)\nlibrary(dplyr)\n\nmd <- dbDriver(\"MySQL\")\ncon <- dbConnect(md, dbname = \"wordpress\", user = \"user\", password = \"pass\", host = \"localhost\")\n\ndbSendQuery(\"select * from wp_posts\") %>%\n  dbFetch() %>%\n  dplyr::filter(post_status == \"publish\")\n<\/code><\/pre>\n<p>SQL \u6587\u3092\u305d\u306e\u307e\u307e\u5b9f\u884c\u3055\u305b\u308b\u3060\u3051\u306a\u306e\u3067\u3001 SQL \u306e\u77e5\u8b58\u304c\u5c11\u3057\u5fc5\u8981\u3068\u306a\u308a\u307e\u3059\u3002<\/p>\n<h4 style=\"border-bottom: solid 4px #73bc9b; margin: 30px 0;\">8. Web\u304b\u3089JSON\u30c7\u30fc\u30bf\u3092\u53d6\u5f97: jsonlite <\/h4>\n<p><a target=\"_blank\" rel=\"nofollow\" href=\"https:\/\/github.com\/jeroen\/jsonlite\">jsonlite<\/a> \u306fWeb\u4e0a\u3067\u516c\u958b\u3055\u308c\u3066\u3044\u308bJSON API\u304b\u3089\u30c7\u30fc\u30bf\u3092\u53d6\u5f97\u3057\u305f\u3044\u6642\u306b\u4f7f\u7528\u3057\u307e\u3059\u3002<br \/>\nJSON\u3092\u53d6\u5f97\u3059\u308b\u3068\u305d\u306e\u307e\u307e\u30c7\u30fc\u30bf\u30d5\u30ec\u30fc\u30e0\u306b\u5909\u63db\u3057\u3066\u304f\u308c\u307e\u3059\u3002<\/p>\n<pre><code class=\"r\">library(jsonlite)\nlibrary(ggplot2)\n\nplot_data <- fromJSON(\"http:\/\/maps.google.com\/maps\/api\/elevation\/json?path=43.0,141.4|26.2,127.7&#038;samples=500&#038;sensor=false\")\n\ngp <- ggplot(plot_data$results, aes(x = location$lng, y = elevation))\ngp + geom_line()\n<\/code><\/pre>\n<p><a target=\"_blank\" href=\"https:\/\/storage.googleapis.com\/sitest-wp\/blog\/wp-content\/uploads\/2017\/04\/jsonlite.png\"><img loading=\"lazy\" src=\"https:\/\/storage.googleapis.com\/sitest-wp\/blog\/wp-content\/uploads\/2017\/04\/jsonlite.png\" alt=\"\" width=\"698\" height=\"406\" class=\"alignnone size-full wp-image-9931\" \/><\/a><br \/>\nGoogle Elevation API \u3092\u5229\u7528\u3057\u3066\u7d4c\u5ea6\u3068\u6a19\u9ad8\u3092\u53d6\u5f97\u3057 ggplot2 \u3067\u6298\u308c\u7dda\u30b0\u30e9\u30d5\u5316\u3057\u3066\u307f\u307e\u3057\u305f\u3002<br \/>\nx\u8ef8\u304c\u7d4c\u5ea6\uff08\u5de6\u304c\u6c96\u7e04\u3001\u53f3\u304c\u5317\u6d77\u9053\uff09\u3001y\u8ef8\u304c\u6a19\u9ad8\u3092\u8868\u3057\u3066\u3044\u307e\u3059\u3002<br \/>\nJSON \u304c\u6271\u3048\u308b\u3060\u3051\u3067 R \u3067\u51fa\u6765\u308b\u3053\u3068\u304c\u3068\u3066\u3082\u5e83\u304c\u308a\u307e\u3059\u306d\u3002<\/p>\n<h4 style=\"border-bottom: solid 4px #73bc9b; margin: 30px 0;\">9. Google Analytics \u304b\u3089\u30c7\u30fc\u30bf\u3092\u53d6\u5f97: RGA <\/h4>\n<p><a target=\"_blank\" rel=\"nofollow\" href=\"https:\/\/github.com\/artemklevtsov\/RGA\">RGA<\/a> \u306f\u3001 Google Analytics \u304b\u3089\u30c7\u30fc\u30bf\u3092\u53d6\u5f97\u3059\u308b\u305f\u3081\u306e\u30d1\u30c3\u30b1\u30fc\u30b8\u3067\u3059\u3002<br \/>\n\u8272\u3005\u306a\u30d1\u30c3\u30b1\u30fc\u30b8\u304c\u3042\u308b\u4e2d\u3067\u3082\u3001 RGA \u306f\u3068\u3066\u3082\u6271\u3044\u3084\u3059\u3044\u30d1\u30c3\u30b1\u30fc\u30b8\u3068\u306a\u308a\u307e\u3059\u3002<br \/>\n\u30d1\u30c3\u30b1\u30fc\u30b8\u306e\u30e1\u30bd\u30c3\u30c9\u306f Google Analytics API \u306b\u6cbf\u3063\u3066\u3044\u307e\u3059\u306e\u3067\u3001API\u3092\u4f7f\u7528\u3055\u308c\u305f\u3053\u3068\u304c\u3042\u308b\u65b9\u306f\u3059\u3050\u306b\u4f7f\u3048\u308b\u3088\u3046\u306b\u306a\u308b\u304b\u3068\u601d\u3044\u307e\u3059\u3002<br \/>\n\u8a73\u3057\u3044\u4f7f\u3044\u65b9\u306f\u5225\u8a18\u4e8b\u306e\u300c<a target=\"_blank\" rel=\"nofollow\" href=\"\"><\/a>\u300d\u3067\u66f8\u3044\u3066\u304a\u308a\u307e\u3059\u306e\u3067\u3001\u305c\u3072\u3054\u4e00\u8aad\u4e0b\u3055\u3044\uff01<\/p>\n<h4 style=\"border-bottom: solid 4px #73bc9b; margin: 30px 0;\">10. \u6c7a\u5b9a\u6728: rpart <\/h4>\n<p><a target=\"_blank\" rel=\"nofollow\" href=\"https:\/\/github.com\/cran\/rpart\">rpart<\/a> \u306f\u3001 R \u3067\u6c7a\u5b9a\u6728\u3092\u4f5c\u308b\u6642\u306b\u4f7f\u7528\u3057\u307e\u3059\u3002<br \/>\n\u30c7\u30d5\u30a9\u30eb\u30c8\u3067\u4ed8\u5c5e\u3057\u3066\u3044\u308b\u30c7\u30fc\u30bf\u30bb\u30c3\u30c8 iris \u3092\u4f7f\u3063\u3066\u3001\u83d6\u84b2\u306e\u5206\u985e\u3092\u3057\u3066\u307f\u307e\u3057\u305f\u3002<br \/>\n\u53ef\u8996\u5316\u306b\u306f rpart.plot \u3068\u3044\u3046\u30d1\u30c3\u30b1\u30fc\u30b8\u3092\u4f7f\u7528\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n<pre><code class=\"r\">library(rpart)\nlibrary(rpart.plot)\nlibrary(magrittr)\n\nrpart(Species ~ ., data = iris) %>%\n  rpart.plot()\n<\/code><\/pre>\n<p><a target=\"_blank\" href=\"https:\/\/storage.googleapis.com\/sitest-wp\/blog\/wp-content\/uploads\/2017\/04\/rpart.png\"><img loading=\"lazy\" src=\"https:\/\/storage.googleapis.com\/sitest-wp\/blog\/wp-content\/uploads\/2017\/04\/rpart.png\" alt=\"\" width=\"579\" height=\"372\" class=\"alignnone size-full wp-image-9934\" \/><\/a><br \/>\nrpart \u3068 rpart.plot \u3092\u4f7f\u3046\u3060\u3051\u3067\u3068\u3066\u3082\u7c21\u5358\u306b\u6c7a\u5b9a\u6728\u3092\u53ef\u8996\u5316\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3057\u305f\u3002<br \/>\n\u3055\u3089\u306b\u6c7a\u5b9a\u6728\u306e\u30e2\u30c7\u30eb\u3068 predict \u95a2\u6570\u3092\u4f7f\u3063\u3066\u3001\u7c21\u5358\u306b\u3067\u306f\u3042\u308a\u307e\u3059\u304c\u4e88\u6e2c\u3092\u884c\u3046\u3053\u3068\u3082\u3067\u304d\u307e\u3059\u306e\u3067\u3001\u6a5f\u68b0\u5b66\u7fd2\u3068\u307e\u3067\u306f\u884c\u304b\u306a\u304f\u3066\u3082\u4e88\u6e2c\u30e2\u30c7\u30eb\u3092\u4f5c\u6210\u3057\u3066\u307f\u305f\u3044\u5834\u5408\u306b\u306f\u4fbf\u5229\u304b\u3068\u601d\u3044\u307e\u3059\u3002<\/p>\n<div class=\"frame_headding\">\n<h3 style=\"text-align: left;\">\u307e\u3068\u3081<\/h3>\n<\/div>\n<p>\u4eca\u56de\u306f R \u3092\u4f7f\u3046\u4e0a\u3067\u4fbf\u5229\u306a\u30d1\u30c3\u30b1\u30fc\u30b8\u3092\u3054\u7d39\u4ecb\u3057\u307e\u3057\u305f\u3002<br \/>\n\u3068\u304f\u306b\u30c7\u30fc\u30bf\u89e3\u6790\u3092\u884c\u3046\u4e0a\u3067\u306f\u3001 dplyr \u3084 ggplot2 \u306f\u5fc5\u9808\u3068\u306a\u308a\u307e\u3059\u3002<br \/>\n\u3057\u3063\u304b\u308a\u3068\u4f7f\u3044\u65b9\u3092\u628a\u63e1\u3057\u3066\u3088\u308a\u5feb\u9069\u306a R \u751f\u6d3b\u3092\u697d\u3057\u307f\u307e\u3057\u3087\u3046\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u307f\u306a\u3055\u3093\u306f R \u8a00\u8a9e\u306e\u30d1\u30c3\u30b1\u30fc\u30b8\u3067\u3069\u306e\u3088\u3046\u306a\u3082\u306e\u3092\u4f7f\u7528\u3055\u308c\u3066\u3044\u307e\u3059\u304b\uff1f R \u3067\u306f CRAN \u3092\u901a\u3057\u3066\u69d8\u3005\u306a\u30d1\u30c3\u30b1\u30fc\u30b8\u304c\u516c\u958b\u30fb\u63d0\u4f9b\u3055\u308c\u3066\u3044\u307e\u3059\u3002 \u4eca\u56de\u306f R \u3067\u7d71\u8a08\u89e3\u6790\u3092\u3059\u308b\u305f\u3081\u306b\u4fbf\u5229\u306a\u304a\u3059\u3059\u3081\u30d1\u30c3\u30b1\u30fc\u30b8\u3092\u3054\u7d39\u4ecb\u3057\u307e\u3059\uff01<\/p>\n","protected":false},"author":1,"featured_media":9786,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[52,47],"tags":[],"acf":false,"_links":{"self":[{"href":"https:\/\/sitest.jp\/blog\/wp-json\/wp\/v2\/posts\/9784"}],"collection":[{"href":"https:\/\/sitest.jp\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/sitest.jp\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/sitest.jp\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/sitest.jp\/blog\/wp-json\/wp\/v2\/comments?post=9784"}],"version-history":[{"count":16,"href":"https:\/\/sitest.jp\/blog\/wp-json\/wp\/v2\/posts\/9784\/revisions"}],"predecessor-version":[{"id":10051,"href":"https:\/\/sitest.jp\/blog\/wp-json\/wp\/v2\/posts\/9784\/revisions\/10051"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/sitest.jp\/blog\/wp-json\/wp\/v2\/media\/9786"}],"wp:attachment":[{"href":"https:\/\/sitest.jp\/blog\/wp-json\/wp\/v2\/media?parent=9784"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/sitest.jp\/blog\/wp-json\/wp\/v2\/categories?post=9784"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/sitest.jp\/blog\/wp-json\/wp\/v2\/tags?post=9784"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}