2019-02-01ãã1ã¶æéã®è¨äºä¸è¦§
ãããªæãã®ãã¼ã¿ããã£ãã¨ããã library(readr) fwf_sample <- readr_example("fwf-sample.txt") cat(read_lines(fwf_sample)) John Smith WA 418-Y11-4111 Mary Hartford CA 319-Z19-4341 Evan Nolan IL 219-532-c301 ããããåºå®é·ãã¼ã¿ã§ããããâ¦
æ°åãã¢ã«ãã¡ãããã«å¤æãããããããã¯ãã®éã§ã¢ã«ãã¡ããããæ°åã«å¤æãããã¨ããã¨ãããã¾ã«ããã¾ãã ä¾ãã°ã11, 12, 13 ãAA, AB, ACã«å¤æãããã¨ããæã§ãã ããããæã¯Rã§ã¯chartr()ãå©ç¨ãã¾ãã chartr("123456789", "ABCDEFGHIâ¦
ãããããã¼ã¿ãããã¨ããã library(dplyr) library(ggplot2) library(gghighlight) ChickWeight_diet <- ChickWeight %>% group_by(Diet, Time) %>% summarise(weight = mean(weight)) > ChickWeight_diet # A tibble: 48 x 3 # Groups: Diet [?] Diet Tâ¦
æå»ãå ¥ãããã¼ã¿ãã¬ã¼ã ãããã¨ããã > smp <- data.frame(now=Sys.time(), then=Sys.time()-60) > smp now then 1 2019-02-09 10:30:15 2019-02-09 10:29:15 ã§ãæå»ã®å·®ãè¨ç®ããã¨ãããã«åä½ãå«ã¾ãã¦ããã > smp$diff <- with(smp, now - thâ¦
åå åãçµåããåã追å ããã°ããã£ã¡ãããã®ã ããggplot2ä¸ã§æå®ããæ¹æ³ããã£ãããªã¨æããªããæãåºããªãã£ã+ã°ã°ãã¥ããã£ãã®ã§ãããåå¿ãinteraction()ã使ãã library(ggplot2) library(dplyr) # ChickWeightãã¼ã¿ã§ååã®ä½éã43以â¦
æè¿æ¬å½ã«å¿ãã£ã½ãã Rã®ããã±ã¼ã¸åãªãã¦ãã¤ã¡ã¼ã¸ã¯æµ®ãã¶ãã®ã®æ£ç¢ºãªå称ãæãåºããªãã ãµãã£ã¨ã°ã°ããã ãã©å½ç¶åºã¦ããªãã ä»æ¹ãªããããè¦ãããããã°ã®è¨äºãç·å½ãããã¦ãã£ã¨è¦ã¤ãããã¨ãã¾ã¾ããã ã¨ãããã¨ã§ããã«ã¡ã¢ãã¦â¦
ã¢ã³ãµã³ãã«å¦ç¿ã¯ä¾¿å©ã ã randomForestãªãLigthGBMãªãXGBoostãªããé©å½ã«ãã¼ã¿ãçªã£è¾¼ãã§ããããªãã®äºæ¸¬ã¢ãã«ãå¾ãããã feature importanceã¨ããå½¢ã§ã©ã®ç¹å¾´éãäºæ¸¬ã«å¹ãã¦ãããããããã ããããã©ãã®ã»ã°ã¡ã³ããæãå¹æçãã¾ã§â¦
æºæã§ãã ä»ã¾ã§ç§ã¯ããåã®æå°å¤ãå«ãè¡ãæ½åºããéãfilter()ãç¨ãã¦ä»¥ä¸ã®ããã«æ¸ãã¦ãã¾ããã library(dplyr) iris %>% filter(Sepal.Length == min(Sepal.Length)) ãããbaseã®æ¸ãæ¹ã§ããã°which.min()ã使ã£ã¦ä»¥ä¸ã®ããã«æ¸ãã¾ãã iriâ¦