2015-12-01ãã1ã¶æéã®è¨äºä¸è¦§
ã²ã¨ãã¢ããã³ãã«ã¬ã³ãã¼24æ¥ç®ã Rã ã¨ãããªãã¨ãã§ããã > "ggplot2" <- "dplyr" > ggplot2 [1] "dplyr" > "ggplot2" [1] "ggplot2" ãããªãã¨ãã§ãããããã«Hadley Wickhamãªã©ã¯library(ggplot2)ã¨æ¸ããã«library("ggplot2")ã¨æ¸ããã¨ãå§ãâ¦
ã²ã¨ãã¢ããã³ãã«ã¬ã³ãã¼23æ¥ç®ã ãã¤ãã®ããã«Advanced Rãèªãã§ããã¨ã次ã®ãããªä¸ç¯ããã£ãã ï¼ããæ¥æã«ç¿»è¨³ãåºã¾ããï¼Rè¨èªå¾¹åºè§£èª¬ä½è : Hadley Wickham,ç³ç°åºåº,å¸å·å¤ªç¥,é«æ³æ ä¸,ç¦å³¶ç太æåºç社/ã¡ã¼ã«ã¼: å ±ç«åºççºå£²æ¥: 2016/02â¦
ã²ã¨ãã¢ããã³ãã«ã¬ã³ãã¼22æ¥ç®ãï¼åç·ã·ãªãã¯ï¼ã·ãªã¢ã«ããã±ã¼ã¸ã¯ãªã¨ã¼ã¿ã¼ï¼æ代ãè¿ããèªä½ããã±ã¼ã¸ãæã£ã¦ããªãã»ããè¦ã¤ããæ¹ãé£ãããªãã¾ããã ãããªèªä½ããã±ã¼ã¸ã®é¢æ°ãRStudioã®ã¡ãã¥ã¼ããã¢ãã¤ã³ã®å½¢ã§å¼ã³åºããããã«â¦
ã²ã¨ãã¢ããã³ãã«ã¬ã³ãã¼21æ¥ç®ã åå¦çãªã©ãã¦ãã¨ãããã¼ãã¼ãããã¿ã¼ã³!!!!ã¨å©ããªããå¥å£°ãããã¦ãã³ã·ã§ã³ãé«ãã¦ãã人ã¯å¤ãã¨æãã¾ãã å人ã®å¥å£°ã«ä»»ããã«Rã®ç°å¢ã¨ãã¦ããããµãã¼ãã§ããªããã ãããªæ³ãã®ãã¨ããã¤ã¦pingsãâ¦
ã²ã¨ãã¢ããã³ãã«ã¬ã³ãã¼20æ¥ç®ã Rããããã°ã©ãã³ã°ã®ä¸çã«å ¥ã£ã人ã¯ä»è¨èªã§ä¼¼ããããªã©ã¤ãã©ãªãæ±ã£ãæã«æ··ä¹±ããå¯è½æ§ãããã ãã¨ãã°ä»¥ä¸ã®æåã¯Rã¦ã¼ã¶ã«ã¨ã£ã¦ã¯ãªããä¸èªç¶ãªãã®ã§ã¯ãªãã > x1 <- 0:9 > x2 <- x1[seq(0,9,by=2)] â¦
ã²ã¨ãã¢ããã³ãã«ã¬ã³ãã¼19æ¥ç®ã Rã§å¯¿å¸ãµã¤ã³ããä½ãããã¨ããã sampleé¢æ°ã使ã£ã¦ä¸æ¦å¯¿å¸ã«æ ¼ç´ããã¨ä»¥ä¸ã®ããã«å¤ã¯åºå®ãããã¾ã¾ã¨ãªãã ã§ãåºå®ãããªãããã«ããæ¹æ³ãããpryrããã±ã¼ã¸ã® %
ã²ã¨ãã¢ããã³ãã«ã¬ã³ãã¼18æ¥ç®ã Advanced Rã«ãããããã«Rã¯é 延è©ä¾¡ãå°å ¥ãã¦ãããããæã£ã¦ãã®ãã¨éããããã¨ããåä½ããã¾ã«ããã ä¾ãã°lapplyé¢æ°ã®æåã > add <- function(x) { + function(y) x + y + } > adders <- lapply(1:10, addâ¦
juliaã¢ããã³ãã«ã¬ã³ãã¼17æ¥ç®ã§ããRã®ä»æ§æ¸ãèªãåã«èªãã§ããããAdvanced Rã®ç¿»è¨³ãæ¥æåºãã¨ãã話ã¯ãã16åããããã¦ãããRè¨èªå¾¹åºè§£èª¬ä½è : Hadley Wickham,ç³ç°åºåº,å¸å·å¤ªç¥,é«æ³æ ä¸,ç¦å³¶ç太æåºç社/ã¡ã¼ã«ã¼: å ±ç«åºççºå£²æ¥: 2016/â¦
ã²ã¨ãã¢ããã³ãã«ã¬ã³ãã¼16æ¥ç®ã ãããããã¼ã¿ã»ããããã£ãã¨ããã > (smp <- data.frame(ID=rep(1:3, 2), + BMI=rep(c(21,26),3), + sbp=rep(c(150,120),3), + nendo=rep(2008:2009, 3) + ) + ) ID BMI sbp nendo 1 1 21 150 2008 2 2 26 120 2009â¦
ã²ã¨ãã¢ããã³ãã«ã¬ã³ãã¼15æ¥ç®ã Rã¯ãããªã«ãã¼ã¿ãå¦çãã¦ãããã®ã§ãé常ã«ä½¿ãåæãè¯ãã ãã®ä¸æ¹ããããªã«å¦çãããã¦ãã¡ããæ³£ããã¿ããã¨ãããã ãã¨ãã°ãRã§ä½¿ããªã人ã¯ããªãã§ãããï¼»é¢æ°ã data.frameã¯ã©ã¹ã«é©ç¨ãããï¼».daâ¦
ã²ã¨ãã¢ããã³ãã«ã¬ã³ãã¼ããã³ãã ã¾ããÃITã¢ããã³ãã«ã¬ã³ãã¼14æ¥ç®ã æ¬è¨äºã§ã¯ãµãã¡ããªã¯ã¹ã«åãçµã¿ã¾ã ãã ã¾ããÃITã¢ããã³ãã«ã¬ã³ãã¼ã¯ä¸è¦è²ç©ã®ãããªã¿ã¤ãã«ã§ãããªããé常ã«ã¬ãã«ã®é«ãã¢ããã³ãã«ã¬ã³ãã¼ã§ãã å¤ãã®äººãâ¦
ã²ã¨ãã¢ããã³ãã«ã¬ã³ãã¼13æ¥ç®ã å¼æ°ãªã¹ããé¢æ°ã«æ¸¡ãã¦å®è¡ãããæããããªæã«do.callé¢æ°ã使ãã¾ãã do.call("mean", list(1:10, na.rm = TRUE)) 誤解ããã¦ããããã§ããããã®do.callé¢æ°ã®ç¬¬ï¼å¼æ°ã¯æååã§ãªãã¦ãOKã§ãã # ä¸ã®ä¾ã¨åâ¦
ã²ã¨ãã¢ããã³ãã«ã¬ã³ãã¼12æ¥ç®ã ãããªè©±ãRã¯ã«ã©ã³ã°ã«æ稿ããã¦ããã WakaTime https://wakatime.com ã¨ãããããã¹ãã¨ãã£ã¿ãªã©ã§ã®ä½æ¥æéãè¨é²ãã¦ãããã¦ã§ããµã¼ãã¹ãé¢ç½ããã§ããªãã¨RStudioãåè£ã«ããã®ã§ãããæ票æ°ãå°ãªãâ¦
ã²ã¨ãã¢ããã³ãã«ã¬ã³ãã¼11æ¥ç®ã Rã«ããã¦ååã¨ãã¦æ°åãè¨å·ããå§ã¾ãå¤æ°åã¯ä½¿ãã¾ããã ããã¯ãã¼ã¿ãã¬ã¼ã ã«ãããååã«ããã¦ãåæ§ã§ãã > data.frame(1var="q") ã¨ã©ã¼: æ³å®å¤ã®ã·ã³ãã«ã§ã in "data.frame(1var" ããããäºæ ãããâ¦
ã²ã¨ãã¢ããã³ãã«ã¬ã³ãã¼10æ¥ç®ã ãã¾ãç¥ããã¦ããªãããã§ãããRã§commenté¢æ°ã使ãã¨ãªãã¸ã§ã¯ãã«ã³ã¡ã³ããã¤ãããã¾ãã comment(iris) <- "好ãã§ã" comment(iris) [1] "好ãã§ã" ããã¯Rã®å±æ§(attributes)ãå©ç¨ãã¦ãã¾ãã é常ãå±æ§â¦
ã²ã¨ãã¢ããã³ãã«ã¬ã³ãã¼9æ¥ç®ã§ãã æ¨æ¥ã¨åã話ãrstanã§ããã£ã¦ã¿ã¾ãã æ¨æ¥ã®ä¾ã¯ä»¥ä¸ã®ãããªãã¸ã¹ãã£ãã¯å帰ã§ããã res_glm <- glm(data=MASS::birthwt, low~age+smoke, family="binomial") ã§ããStanã®ã³ã¼ããæ¸ããããªãã ã¨ãããã¨â¦
以åãã¸ã¹ãã£ãã¯å帰ã®çµæãæ´å½¢ãã¦è¡¨ç¤ºããã¨ããè¨äºãæ¸ãã¾ããã ä»åã¯æ´å½¢ããçµæãDiagrammeRãç¨ãã¦å¯è¦åãã¦ã¿ã¾ãã ã¾ãã¯ã¢ãã«ãä½ãã¾ããååã¨åããã¸ã¹ãã£ãã¯å帰ã®ã¢ãã«ã§ãã > res_glm <- glm(data=MASS::birthwt, low~ageâ¦
ã²ã¨ãã¢ããã³ãã«ã¬ã³ãã¼ï¼æ¥ç®ã data.tableåã«å¯¾ãã¦colnamesãªã©ãé©ç¨ããã¨ä¸ã®ãããªè¦åãåºãã > library("data.table") > smp <- as.data.table(iris) > colnames(smp) <- colnames(smp) è¦åã¡ãã»ã¼ã¸: In `names<-.data.table`(`*tmp*`, vaâ¦
ã²ã¨ãã¢ããã³ãã«ã¬ã³ãã¼ï¼æ¥ç®ã glm使ã£ã¦ãªããºæ¯ãç®åºããªããããã¼ãã®è¾ºèªåçã«ãã£ã¦ãããããã±ã¼ã¸ãã£ããªã¨æãã ããã epiCalcã¨ããããã±ã¼ã¸ã§ã該å½é¢æ°ã¯logistic.displayã ããCRANãããªã ã¼ãããã¦ããã https://cran.r-projâ¦
ã²ã¨ãã¢ããã³ãã«ã¬ã³ãã¼ï¼æ¥ç®ã ãã¼ããã¦ããããã±ã¼ã¸ãã¤ã³ã¹ãã¼ã«ãããã¨ããã¨ã¨ã©ã¼ã«ãªãã > library("ggplot2") > install.packages("ggplot2") Error in install.packages : Updating loaded packages ãããªæã¯ãããã±ã¼ã¸ãã¢ã³ãã¼â¦
ã²ã¨ãã¢ããã³ãã«ã¬ã³ãã¼ï¼æ¥ç®ã Rçã®ç¥ã¨ããã°Hadley Wickhamã library("ggmap") ggimage(hadley) å½¼ãæ¸ããã®ãAdvanced Rã§ãé¦è¨³ãããããåºããRè¨èªå¾¹åºè§£èª¬ä½è : Hadley Wickham,ç³ç°åºåº,å¸å·å¤ªç¥,é«æ³æ ä¸,ç¦å³¶ç太æåºç社/ã¡ã¼ã«ã¼: å ±â¦
ã²ã¨ãã¢ããã³ãã«ã¬ã³ãã¼ï¼æ¥ç®ã URLãã¹ã©ãã·ã¥ã§åå²ãç¹å®ã®è¦ç´ ãæ½åºãããã¨ããã æååã®åå²ã¯çµã¿è¾¼ã¿é¢æ°ã ã¨str_splité¢æ°ãããã®ã§ããã使ã£ã¦ã¿ãã library("dplyr") > (dat <- data.frame(URL=c("http://notchained.hatenablog.com/â¦
ã²ã¨ãã¢ããã³ãã«ã¬ã³ãã¼2æ¥ç®ã 以ä¸ã®ã³ã¼ãã®å®è¡çµæã¯çããäºæ³ã§ããã ãããã x1 <- c(a=1, a=2, a=3, b=1, b=2, b=3) x2 <- c(a=1:3, b=4:6) çµæã¯ãã¡ãã > x1 a a a b b b 1 2 3 1 2 3 > x2 a1 a2 a3 b1 b2 b3 1 2 3 4 5 6 ä»åº¦ã¯ãã¡ãã®â¦
ãããä¸è¬ã¦ã¼ã¶ã¼ããRã§ã¯ã©ã¹ã¨ã使ãããã¼ãã使ãããã¼ã¨ãã人ãå¤ãã¨æãã¾ãã ãããS3ã¯ã©ã¹ã¯ä¾¿å©ã§ãã ãã¨ãã°printé¢æ°ã®æåãã¿ã¦ã¿ã¾ãããã 以ä¸ã¯ã·ã³ãã«ãªå åãprintããä¾ã§ãã > smp <- factor("a") > print(smp) [1] a Leveâ¦