R による統計解析入門

Similar documents
BMIdata.txt DT DT <- read.table("bmidata.txt") DT head(dt) names(dt) str(dt)

2.1 R, ( ), Download R for Windows base. R ( ) R win.exe, 2.,.,.,. R > 3*5 # [1] 15 > c(19,76)+c(11,13)

2 R : R R [ 1.1] [ 2.1] R R R plot() contour() 2

!!! 2!

1.2 R R Windows, Macintosh, Linux(Unix) Windows Mac R Linux redhat, debian, vinelinux ( ) RjpWiki ( RjpWiki Wiki

R int num factor character 1 2 (dichotomous variable) (trichotomous variable) 3 (nominal scale) M F 1 2 coding as.numeric() as.integer() 2

1 R Windows R 1.1 R The R project web R web Download [CRAN] CRAN Mirrors Japan Download and Install R [Windows 9

Excel97関数編

3 Java 3.1 Hello World! Hello World public class HelloWorld { public static void main(string[] args) { System.out.println("Hello World");

dicutil1_5_2.book


untitled

untitled



2.2 Sage I 11 factor Sage Sage exit quit 1 sage : exit 2 Exiting Sage ( CPU time 0m0.06s, Wall time 2m8.71 s). 2.2 Sage Python Sage 1. Sage.sage 2. sa

Rの基本的な使い方

C言語によるアルゴリズムとデータ構造

PC Windows 95, Windows 98, Windows NT, Windows 2000, MS-DOS, UNIX CPU

5 5.1 A B mm 0.1mm Nominal Scale 74


ECCS. ECCS,. ( 2. Mac Do-file Editor. Mac Do-file Editor Windows Do-file Editor Top Do-file e

23_33.indd

Excel ではじめる数値解析 サンプルページ この本の定価 判型などは, 以下の URL からご覧いただけます. このサンプルページの内容は, 初版 1 刷発行時のものです.

1 I EViews View Proc Freeze

R John Fox R R R Console library(rcmdr) Rcmdr R GUI Windows R R SDI *1 R Console R 1 2 Windows XP Windows * 2 R R Console R ˆ R

1. A0 A B A0 A : A1,...,A5 B : B1,...,B

第10回 コーディングと統合(WWW用).PDF

統計研修R分散分析(追加).indd

double float

untitled

¥¤¥ó¥¿¡¼¥Í¥Ã¥È·×¬¤È¥Ç¡¼¥¿²òÀÏ Âè2²ó


Java演習(4) -- 変数と型 --

¥ƥ­¥¹¥ȥ¨¥ǥ£¥¿¤λȤ¤˽

3 3.1 SSedit ua012345% ssedit SuperSQL config.ssql log.txt( logs.txt) SSedit SSedit 3.2 ssql Putty SSedit ua012345% ssql HTML /public html/ssql.ssql 4

Copyright c 2006 Zhenjiang Hu, All Right Reserved.

k2 ( :35 ) ( k2) (GLM) web web 1 :

¥¤¥ó¥¿¡¼¥Í¥Ã¥È·×¬¤È¥Ç¡¼¥¿²òÀÏ Âè2²ó

¥×¥í¥°¥é¥ß¥ó¥°±é½¬I Exercise on Programming I [1zh] ` `%%%`#`&12_`__~~~ alse

: Shift-Return evaluate 2.3 Sage? Shift-Return abs 2 abs? 2: abs 3: fac

yamadaiR(cEFA).pdf

28 9

GNUPLOT GNUPLOT GNUPLOT 1 ( ) GNUPLO

R Console >R ˆ 2 ˆ 2 ˆ Graphics Device 1 Rcmdr R Console R R Rcmdr Rcmdr Fox, 2007 Fox and Carvalho, 2012 R R 2

SAS Enterprise Miner PFD SAS Rapid Predictive Modeler & SAS SEMMA 5 SEMMA SAS Rapid Predictive Modeler SAS Rapid Predictive Modeler SAS Enterprise Gui

II ( ) prog8-1.c s1542h017%./prog8-1 1 => 35 Hiroshi 2 => 23 Koji 3 => 67 Satoshi 4 => 87 Junko 5 => 64 Ichiro 6 => 89 Mari 7 => 73 D

インターネットマガジン2001年9月号―INTERNET magazine No.80

win版8日目

NetSkate

事例に見るSCORMの・・・

データ分析のまとめ方

10-C.._241_266_.Z

pressnet_g36ill.indd

Exam : A JPN Title : SAS Base Programming for SAS 9 Vendor : SASInstitute Version : DEMO Get Latest & Valid A JPN Exam's Question and Answ

DAA09

講義のーと : データ解析のための統計モデリング. 第3回

Microsoft Word - C.....u.K...doc

明解Javaによるアルゴリズムとデータ構造

8日目

新・明解Javaで学ぶアルゴリズムとデータ構造

() (MeCab) *1 Juman ChaSen *2 MeCab ChaSen 1.3 MeCab MeCab OS Windows MeCab [] [Binary package for MS-Windows] [] sourceforge.net [mecab-win32] Mac OS

i I Excel iii Excel Excel Excel

fx-9860G Manager PLUS_J

spss1.PDF

Rによる計量分析:データ解析と可視化 - 第2回 セットアップ

Microsoft Word - 卒業研究Ⅱ論文.docx

untitled

コンピュータ概論

新コンフィギュレータのフレームワークについて

[1] Excel Excel... [3]. CSV RDF. [4] LinkedData. [5] LinkedData 1 RDF. OLAP. OLAP. [6] RDBMS. Excel CSV. CSV JSON RDF. Excel RDF. RDF RDF..

Rによる計量分析:データ解析と可視化 - 第3回 Rの基礎とデータ操作・管理

Microsoft Word - colors

class IntCell { private int value ; int getvalue() {return value; private IntCell next; IntCell next() {return next; IntCell(int value) {this.value =

新・明解C言語で学ぶアルゴリズムとデータ構造

1 1.1 PC PC PC PC PC workstation PC hardsoft PC PC CPU 1 Gustavb, Wikimedia Commons.

haskell.gby

101NEO資料

16soukatsu_p1_40.ai

Gray [6] cross tabulation CUBE, ROLL UP Johnson [7] pivoting SQL 3. SuperSQL SuperSQL SuperSQL SQL [1] [2] SQL SELECT GENERATE <media> <TFE> GENER- AT

1

Solution Report

(OnePoint) ( URL Web Copyright 2005 Microsoft Corporation. All rights reserved. Microsoft Windows Visual Basic Visual Studio Microsoft Corporation

第2回:データの加工・整理

kubostat2017c p (c) Poisson regression, a generalized linear model (GLM) : :


Java updated

8 if switch for while do while 2

ProVAL Recent Projects, ProVAL Online 3 Recent Projects ProVAL Online Show Online Content on the Start Page Page 13

1 2 Windows 7 *3 Windows * 4 R R Console R R Console ˆ R GUI R R R *5 R 2 R R R 6.1 ˆ 2 ˆ 2 ˆ Graphics Device 1 Rcmdr R Console R Rconsole R --sdi R M


I 11

kubostat2015e p.2 how to specify Poisson regression model, a GLM GLM how to specify model, a GLM GLM logistic probability distribution Poisson distrib

PowerPoint Presentation

Stata13 Stata long/wide whitepaper mwp mcode import excel Excel / 4 mwp-092 import delimited 10 mwp-195 infix 17 mwp-031 infile 23 mwp-080 append 29 m

Rプログラミング

MICROLINK マリオネット 操作説明書

AC-1 procedure AC-1 (G) begin Q = f(i; j) (i; j) 2 arc(g), i 6= jg repeat begin CHANGE = false for each (i; j) 2 Q do CHANGE = REVISE((i; j)) _ CHANGE

学校では教えてくれないアセットバンドル

Transcription:

R May 31, 2016

R R R R Studio GUI R Console R Studio PDF URL http://ruby.kyoto-wu.ac.jp/konami/text/r

R R Console Windows, Mac GUI Unix R Studio GUI

R version 3.2.3 (2015-12-10) -- "Wooden Christmas-Tree" Copyright (C) 2015 The R Foundation for Statistical Computing Platform: x86_64-pc-linux-gnu (64-bit) R license() licence() R contributors() R R citation() demo() help() help.start() HTML q() R >

demo() Demos in package base : error.catching is.things recursion scoping More examples on catching and handling errors Explore some properties of R objects and is.foo() functions. Not for newbies! Using recursion for adaptive integration An illustration of lexical scoping. Demos in package grdevices : colors hclcolors A show of R s predefined colors() Exploration of hcl() space (stdin): q

base error.catching, is.things, recursion, scoping grdevices colors, hclcolors graphics Hershey, Japanese, graphics, image, persp, plotmath stats glm.vr, lm.glm, nlm, smooth colors, graphics, persp > demo(recursion)

R # > a <- 50 # = > b <- 30 # = > c <- a + b < c # [1] 80 # abc, name, x, y sum1( ) mean_total( ) Sum( ), Member.female( ) if else repeat while function for in next break TRUE FALSE NULL NA Inf NaN

data, sum, summary, mean, median, max, mean, sqrt, sin, cos Data, DATA, DT Data.sum, DATA.mean D 1 C, F, I, T > sum function (..., na.rm = FALSE).Primitive("sum") > Sum : Sum sum Sum

c > X <- c(10.2,20.5,-2.9,13.8,9.1,23.1) > X [1] 10.2 20.5-2.9 13.8 9.1 23.1 > X[4] [1] 13.8 # 1 > X[2:4] [1] 20.5-2.9 13.8 > X[-3] [1] 10.2 20.5 13.8 9.1 23.1 # 3 > order(x) [1] 3 5 1 4 2 6 # > sort(x) [1] -2.9 9.1 10.2 13.8 20.5 23.1 sum, mean, median, min, max, length X

> var(x) # [1] 86.364 > sd(x) # [1] 9.293223 > quantile(x) # 0% 25% 50% 75% 100% -2.900 9.375 12.000 18.825 23.100 > quantile(x,0.25) # 25% 9.375 > quantile(x,0.75) # 75% 18.825 > summary(x) # Min. 1st Qu. Median Mean 3rd Qu. Max. -2.900 9.375 12.000 12.300 18.820 23.100

, ff 2 = 1 n ` 1 nx (x i ` ) 2 ; ff = 1 q ff 2 n x 1 ; x 2 ; ; x n n ff 2 = 1 n nx (x i ` ) 2 ; ff = 1 q ff 2 25% 75% 5

> X <- c(10.2,20.5,-2.9,13.8,9.1,23.1) > Y <- c(6.8,10.1,5.4,9.1,9.1,1.1) > Z <- c(1.32,3.24,0.98,0.55,1.67,2.3) cbind (column) (bind) > Mat <- cbind(x,y,z) > Mat X Y Z [1,] 10.2 6.8 1.32 [2,] 20.5 10.1 3.24 [3,] -2.9 5.4 0.98 [4,] 13.8 9.1 0.55 [5,] 9.1 9.1 1.67 [6,] 23.1 1.1 2.30

rbind (row) < rbind(x,y,z) [,1] [,2] [,3] [,4] [,5] [,6] X 10.20 20.50-2.90 13.80 9.10 23.1 Y 6.80 10.10 5.40 9.10 9.10 1.1 Z 1.32 3.24 0.98 0.55 1.67 2.3 cbind > dim(mat) [1] 6 3 > dim(rbind(x,y,z)) [1] 3 6 > dim(mat)[1] # dim() [1] 6 > dim(mat)[2] [1] 3

> Mat[2,3] Z 3.24 > Mat[2,] X Y Z 20.50 10.10 3.24 > Mat[,3] [1] 1.32 3.24 0.98 0.55 1.67 2.30 > Mat[,] X Y Z [1,] 10.2 6.8 1.32 [2,] 20.5 10.1 3.24 [3,] -2.9 5.4 0.98 [4,] 13.8 9.1 0.55 [5,] 9.1 9.1 1.67 [6,] 23.1 1.1 2.30 Mat[,], Mat[2,], Mat[,3]

NA (not available) > V <- c(10,20,30,na,50,60) > sum(v) [1] NA > mean(v) [1] NA > var(v) [1] NA > sum(v,na.rm=true) [1] 170 > mean(v,na.rm=true) [1] 34 > var(v,na.rm=true) [1] 430 sum, mean, var NA na.rm = TRUE na.rm = T

list list > N <- c("a","b","c","d") > List <- list(mat=mat,val=v,name=n) > List $Mat X Y Z [1,] 10.2 6.8 1.32 [2,] 20.5 10.1 3.24 [3,] -2.9 5.4 0.98 [4,] 13.8 9.1 0.55 [5,] 9.1 9.1 1.67 [6,] 23.1 1.1 2.30 $val [1] 10 20 30 NA 50 60 $name [1] "a" "b" "c" "d"

$ > names(list) # List [1] "Mat" "val" "name" > List$Mat X Y Z [1,] 10.2 6.8 1.32 [2,] 20.5 10.1 3.24 [3,] -2.9 5.4 0.98 [4,] 13.8 9.1 0.55 [5,] 9.1 9.1 1.67 [6,] 23.1 1.1 2.30 > List$val [1] 10 20 30 NA 50 60 > List$name [1] "a" "b" "c" "d" R

(CSV ) Excel.xls,.xlsx Excel CSV xls, xlsx

Windows Windows R (C:, D: ) n R / Unix Windows CP932 (Shit-JIS) Mac, Linux UTF-8 Windows Rscript Windows Windows R C:\R C:\home\R Path (3.3.0 ) C:\Program Files\R\R-3.3.0\bin

BMI.txt Name Sex Height Weight Yuri F 155.6 54.3 Miwa F 164.2 63.2 Saki F 158.3 52.3 Taiki M 171.4 84.4 Tarou M 191.5 76.4 Kei M 178.5 75.3 > setwd("c:/r/mydata") # > BMI <- read.table("bmidata.txt",header=true) # > class(bmi) # BMI [1] "data.frame" > names(bmi) # [1] "Name" "Sex" "Height" "Weight"

> BMI # Name Sex Height Weight 1 Yuri F 155.6 54.3 2 Miwa F 164.2 63.2 3 Saki F 158.3 52.3 4 Taiki M 171.4 84.4 5 Tarou M 191.5 76.4 6 Kei M 178.5 75.3 > str(bmi) # BMI data.frame : 6 obs. of 4 variables: $ Name : Factor w/ 6 levels "Kei","Miwa","Saki",..: 6 2 3 4 5 1 $ Sex : Factor w/ 2 levels "F","M": 1 1 1 2 2 2 $ Height: num 156 164 158 171 192... $ Weight: num 54.3 63.2 52.3 84.4 76.4 75.3 > summary(bmi$height) # Height Min. 1st Qu. Median Mean 3rd Qu. Max. 155.6 159.8 167.8 169.9 176.7 191.5 > summary(bmi$sex) # F M 3 3

> BMI_F <- BMI[BMI$Sex=="F",] # > BMI_M <- BMI[BMI$Sex=="M",] # > max(bmi_f$height) # [1] 164.2 > mean_h <- mean(bmi$height) # > Higher <- BMI[BMI$Height>mean_H,] # > Higher Name Sex Height Weight 4 Taiki M 171.4 84.4 5 Tarou M 191.5 76.4 6 Kei M 178.5 75.3

CSV Score.csv NA URL http://ruby/kyoto-wu.ac.jp/konami/text/r/ 1 2 3,,,,,,,F,69,80,58,,F,92,60,78,,M,59,79,63,,M,NA,NA,89