mean(sample (1:6, 100, replace = TRUE))
mean(sample (1:6, 100, replace = TRUE))
## サイコロめE丁E振るシミュレーションのヒストグラ
res <- sample(1:6, 10000, replace = TRUE)
hist(res)
saikoro <- data.frame(サイコロ = res)
head (saikoro)
ggplot(saikoro, aes (x = サイコロ)) + xlim(1,6) + geom_histogram(binwidth = 1 , fill = "steelblue", colour="black",  alpha = 0.5) + xlab("出た数") + ylab ("回数") + ggtitle("サイコロめE丁E振った結果") + theme(plot.title = element_text(size=22), axis.title.x = element_text(size=22),axis.title.y = element_text(size=22))
## サイコロの期征E
set.seed(123)#乱数の種を設宁E試行E再現性を保証)
# 10丁Eの試衁Esikou <- 100000
res <- numeric (sikou)
for (i in seq.int (sikou)){
res [i] <- mean (sample(1:6, 100, replace = TRUE))
}
## シンプルなヒストグラ
hist(res)
## もう少し凝ったグラフを生E
library(ggplot2)
saikoro <- data.frame(サイコロ = res)
head (saikoro)
ggplot(saikoro, aes (x = サイコロ)) + geom_histogram(binwidth = .1, fill = "steelblue", colour="black",  alpha = 0.5) + xlab("期征E") + ylab ("回数") + ggtitle("サイコロめE00回振った期征E") + theme(plot.title = element_text(size=22), axis.title.x = element_text(size=22),axis.title.y = element_text(size=22))
kuji <- c("外れ","1筁E)
sample(kuji, 100, prob = c(99,1), replace = TRUE)
sample(kuji, 100, prob = c(99,1), replace = TRUE)
hist (sample (1:6, 10000, replace = TRUE), breaks = 0:6)
hist(sample(1:6,100,replace=TRUE),breaks=0:6)
set.seed(123)#乱数の種を設宁E試行E再現性を保証)
x <- c(rep(0,990), rep(1,10));
y <- numeric(100)
z <- numeric(7)
res <- numeric(1000)
## ここから100週刁Eシミュレーション
for (h in 1:1000){
for (j in 1:7){
for (i in 1:100) {
y[i] <- sample(x,1)
tmp <- which(x == y[i])[1]
#  cat(tmp, "\t")
if(length(tmp) > 0 )  x <- x[-tmp]
}
z[j] <- sum(y)
x <- c(rep(0,990), rep(1,10));
}
res[h] <- sum(z)
}
table(res);sum (table(res))
hist(res, breaks = 17)
res <- sample(1:6, 10000, replace = TRUE)
## シンプルなヒストグラ
hist(res)
set.seed(123)#乱数の種を設宁E試行E再現性を保証)
# 10丁Eの試衁Esikou <- 100000
res <- numeric (sikou)
for (i in seq.int (sikou)){
res [i] <- mean (sample(1:6, 100, replace = TRUE))
}
## シンプルなヒストグラ
hist(res)
## もう少し凝ったグラフを生E
library(ggplot2)
saikoro <- data.frame(サイコロ = res)
head (saikoro)
ggplot(saikoro, aes (x = サイコロ)) + geom_histogram(binwidth = .1, fill = "steelblue", colour="black",  alpha = 0.5) + xlab("期征E") + ylab ("回数") + ggtitle("サイコロめE00回振った期征E") + theme(plot.title = element_text(size=22), axis.title.x = element_text(size=22),axis.title.y = element_text(size=22))
ggplot(saikoro, aes (x = サイコロ)) + geom_histogram(binwidth = .1, fill = "steelblue", colour="black",  alpha = 0.5) + xlab("期征E") + ylab ("回数") + ggtitle("サイコロめE0丁E振った期征E") + theme(plot.title = element_text(size=22), axis.title.x = element_text(size=22),axis.title.y = element_text(size=22))
set.seed(123)
"0 = 外れ" 990 本,  1 = "一筁E 10 本
x <- sample(c(rep(0,990), rep(1,10)))
res  <- replicate(1000, sum (replicate(7, sum(sample (x, 100)) )) )
table(res);sum (table(res))
hist(res, breaks = 17)
res  <- replicate(10000, sum (replicate(7, sum(sample (x, 100)) )) )
hist(res, breaks = 17)
res  <- replicate(100000, sum (replicate(7, sum(sample (x, 100)) )) )
hist(res, breaks = 17)
if(!require(ggplot2, quietly = TRUE)) install.packages("ggplot2")
ggplot (breads, aes(x = weight)) + geom_histogram(binwidth = 10, fill = "steelblue", colour="black",  alpha = 0.5) + xlab("食パンの重さ") + ylab ("個数") + ggtitle("食パンのヒストグラ
")
breads <- read.csv ("breads.csv")
ggplot (breads, aes(x = weight)) + geom_histogram(binwidth = 10, fill = "steelblue", colour="black",  alpha = 0.5) + xlab("食パンの重さ") + ylab ("個数") + ggtitle("食パンのヒストグラ
")
ggplot(saikoro, aes (x = サイコロ)) + geom_histogram(aes(y = ..density..), binwidth = 0.5, fill = "steelblue", colour="black",  alpha = 0.5) + xlim(1,6) + stat_function(geom="line", fun = dnorm, args=list(mean = 3.5, sd = 0.54)) + ggtitle("サイコロの平坁Eの平坁E") + ylab("") + xlab("期征Eは3.5")#
set.seed(123)#乱数の種を設宁E試行E再現性を保証)
# 10丁Eの試衁Esikou <- 100000
res <- numeric (sikou)
for (i in seq.int (sikou)){
res [i] <- mean (sample(1:6, 10, replace = TRUE))
}
mean(res); sd (res)
saikoro <- data.frame(サイコロ = res)
head (saikoro)
ggplot(saikoro, aes (x = サイコロ)) + geom_histogram(aes(y = ..density..), binwidth = 0.5, fill = "steelblue", colour="black",  alpha = 0.5) + xlim(1,6) + stat_function(geom="line", fun = dnorm, args=list(mean = 3.5, sd = 0.54)) + ggtitle("サイコロの平坁Eの平坁E") + ylab("") + xlab("期征Eは3.5")#
## 白ひげE生E食パンチEEタ。その95%篁E
mean (breads$weight) -  sd (breads$weight)*2
mean (breads$weight) +  sd (breads$weight)*2
ggplot (breads, aes(x = weight))+ geom_histogram(aes(y = ..density..),binwidth = 10, fill = "steelblue", colour="black",  alpha = 0.5) + xlim(360, 430)  + xlab("食パンの重さ") + ylab ("個数") + ggtitle("食パンのヒストグラ
") + stat_function(geom="line", fun = dnorm, args=list(mean = mean (breads$weight), sd = sd (breads$weight)))
q()
if(!require (RMeCab)){ install.packages("RMeCab", repos = "http://rmecab.jp/R"); library(RMeCab) }
if(!require (RMeCab)){ install.packages("RMeCab", repos = "http://rmecab.jp/R"); library(RMeCab) }
m <- NgramDF("merosu.txt", type = 1, pos = c("名詁E,"形容詁E, "動詁E))
head (m)
m.df <- m [m$Freq > 2, ]
## ネットワークグラフを描く準備
if(!require (igraph)){  install.packages("igraph"); library(igraph) }
m.g <- graph.data.frame(m.df)
E(m.g)$weight <- m.df[,3] #
tkplot(m.g, vertex.label =V(m.g)$name, edge.label =E(m.g)$weight , vertex.size = 23)#グラフE色の設定が忁EEE#Rから形態
解析器MeCabを使ぁEめに追
パッケージをインストEル
install.packages("RMeCab", repos = "http://rmecab.jp/R")
library(RMeCab) # パッケージを読み込む
# 太宰治『走れメロス』E斁E形態
解析して単語Eつながりを
度表に変えめEm <- NgramDF("merosu.txt", type = 1, pos = c("名詁E,"形容詁E, "動詁E))
head (m) # 結果の冒
部刁E確誁Em.df <- m [m$Freq > 2, ]# 頻度ぁEを趁Eる単語に絞ってみめE## ネットワークグラフを描くパッケージを導E
install.packages("igraph")
library(igraph) # パッケージの読み込み
m.g <- graph.data.frame(m.df)#頻度表をネチEワーク化すめEE(m.g)$weight <- m.df[,3] #頻度EE数値Eを重要度とみなぁE# 実際にネットワーク図を描く（新しいウィンドウが表示される！Etkplot(m.g, vertex.label =V(m.g)$name, edge.label =E(m.g)$weight , vertex.size = 23)
# フォルダごとファイルを解极Em <- docNgram ("bungo", type = 0)
m <- docNgram ("bungo", type = 0)
if(!require (RMeCab)){ install.packages("RMeCab", repos = "http://rmecab.jp/R"); library(RMeCab) }
m <- NgramDF("merosu.txt", type = 1, pos = c("名詁E,"形容詁E, "動詁E))
head (m)
m.df <- m [m$Freq > 2, ]
## ネットワークグラフを描く準備
if(!require (igraph)){  install.packages("igraph"); library(igraph) }
m.g <- graph.data.frame(m.df)
E(m.g)$weight <- m.df[,3] #
# Macの場合、XquartzのインストEルが忁EEhttp://xquartz.macosforge.org/landing/
tkplot(m.g, vertex.label =V(m.g)$name, edge.label =E(m.g)$weight , vertex.size = 23)#グラフE色の設定が忁EEEif(!require (RMeCab)){ install.packages("RMeCab", repos = "http://rmecab.jp/R"); library(RMeCab) }
m <- docNgram ("bungo", type = 0)
source ("http://rmecab.jp/R/Rprofile.R")
1+2
2*3*4
8/4/2
1+2
2*3*4
8/4/2
1:10
p <- ggplot(data.frame(x = randNorm , y = randDensity)) + aes(x = x , y = y) + geom_line() + labs(x = "x" , y = "確玁EE")
randNorm <- rnorm(30000)
randDensity <- dnorm(randNorm)
p <- ggplot(data.frame(x = randNorm , y = randDensity)) + aes(x = x , y = y) + geom_line() + labs(x = "x" , y = "確玁EE")
p
neg1Seq <- seq(from = min(randNorm) , to = -1 , by = 1)
neg2Seq <- seq(from = min(randNorm) , to = -2 , by = .1)
neg1Seq <- seq(from = min(randNorm) , to = -1 , by = .1)
lessthanNeg2 <- deta.frame(x = neg2Seq , y = dnorm(neg2Seq))
lessthanNeg2 <- data.frame(x = neg2Seq , y = dnorm(neg2Seq))
lessThanNeg2 <- rbind(c(min(randNorm) , 0 ) ,)
lessThanNeg2 <- rbind(c(min(randNorm) , 0 ) , +)
lessThanNeg2 <- rbind(c(min(randNorm) , 0 ) , lessthanNeg2 , c(max(lessthanNeg2$x) , 0)
)
p + geom_polygon(data = lessThanNeg2 , aes(x = x , y = y))
p + geom_polygon(data = lessThanNeg2 , aes(x = x , y = y) , fill = gray20)
p + geom_polygon(data = lessThanNeg2 , aes(x = x , y = y) , fill = "gray")
p + geom_polygon(data = lessThanNeg2 , aes(x = x , y = y) , fill = "gray50")
neg2Pos2Seq <- seq(from = -2 , to = 2 , by = .1)
neg2To2 <- data.frame(x = neg2Pos2Seq , y = dnorm(neg2Pos2Seq))
neg2To2 <- rbind(c(min(neg2To2$x) , 0 ) , neg2To2 , c(max(neg2To2$x) , 0))
p + geom_polygon(data = neg2To2 , aes(x = x , y = y) , fill = "gray20")
p + geom_polygon(data = neg2To2 , aes(x = x , y = y) , fill = "gray80")
neg1Pos1Seq <- seq(from = -1 , to = 1 , by = .1)
neg1To1 <- data.frame(x = neg1Pos1Seq , y = dnorm(neg1Pos1Seq))
neg1To1 <- rbind(c(min(neg1To1$x) , 0 ) , neg1To1 , c(max(neg1To1$x) , 0))
Pos2Seq <- seq(from = 2 , to = max(randNorm) , by = .1)
moreThanPos2 <- data.frame(x = Pos2Seq , y = dnorm(Pos2Seq))
moreThanPos2 <- rbind(c(min(moreThanPos2$x) , 0 ) , moreThanPos2 , c(max(randNorm) , 0))
p + geom_polygon(data = neg2To2 , aes(x = x , y = y) , fill = "gray80")
+ geom_polygon(data = neg1To1 , aes(x = x , y = y) , fill = "gray60")
+ geom_polygon(data = lessThanNeg2 , aes(x = x , y = y) , fill = "gray40")
+ geom_polygon(data = moreThanPos2 , aes(x = x , y = y) , fill = "gray40")
randNorm <- rnorm(30000)
randDensity <- dnorm(randNorm)
p <- ggplot(data.frame(x = randNorm , y = randDensity)) + aes(x = x , y = y) + geom_line() + labs(x = "x" , y = "確玁EE")
neg1Seq <- seq(from = min(randNorm) , to = -1 , by = .1)
neg2Seq <- seq(from = min(randNorm) , to = -2 , by = .1)
lessThanNeg2 <- data.frame(x = neg2Seq , y = dnorm(neg2Seq))
lessThanNeg2 <- rbind(c(min(randNorm) , 0 ) , lessThanNeg2 , c(max(lessThanNeg2$x) , 0))
p + geom_polygon(data = lessThanNeg2 , aes(x = x , y = y) , fill = "gray50")
neg2Pos2Seq <- seq(from = -2 , to = 2 , by = .1)
neg2To2 <- data.frame(x = neg2Pos2Seq , y = dnorm(neg2Pos2Seq))
neg2To2 <- rbind(c(min(neg2To2$x) , 0 ) , neg2To2 , c(max(neg2To2$x) , 0))
p + geom_polygon(data = neg2To2 , aes(x = x , y = y) , fill = "gray80")
neg1Pos1Seq <- seq(from = -1 , to = 1 , by = .1)
neg1To1 <- data.frame(x = neg1Pos1Seq , y = dnorm(neg1Pos1Seq))
neg1To1 <- rbind(c(min(neg1To1$x) , 0 ) , neg1To1 , c(max(neg1To1$x) , 0))
Pos2Seq <- seq(from = 2 , to = max(randNorm) , by = .1)
moreThanPos2 <- data.frame(x = Pos2Seq , y = dnorm(Pos2Seq))
moreThanPos2 <- rbind(c(min(moreThanPos2$x) , 0 ) , moreThanPos2 , c(max(randNorm) , 0))
p + geom_polygon(data = neg2To2 , aes(x = x , y = y) , fill = "gray80")
+ geom_polygon(data = neg1To1 , aes(x = x , y = y) , fill = "gray60")
p + geom_polygon(data = neg2To2 , aes(x = x , y = y) , fill = "gray80") + geom_polygon(data = neg1To1 , aes(x = x , y = y) , fill = "gray60") + geom_polygon(data = lessThanNeg2 , aes(x = x , y = y) , fill = "gray40") + geom_polygon(data = moreThanPos2 , aes(x = x , y = y) , fill = "gray40")
p + geom_polygon(data = neg1To1 , aes(x = x , y = y) , fill = "gray80") + geom_polygon(data = neg2To2 , aes(x = x , y = y) , fill = "gray60") + geom_polygon(data = lessThanNeg2 , aes(x = x , y = y) , fill = "gray40") + geom_polygon(data = moreThanPos2 , aes(x = x , y = y) , fill = "gray40")
p + geom_polygon(data = neg2To2 , aes(x = x , y = y) , fill = "gray60") + geom_polygon(data = neg1To1 , aes(x = x , y = y) , fill = "gray80") + geom_polygon(data = lessThanNeg2 , aes(x = x , y = y) , fill = "gray40") + geom_polygon(data = moreThanPos2 , aes(x = x , y = y) , fill = "gray40")
geom_polygon(data = neg2To2 , aes(x = x , y = y) , fill = "gray60") + geom_polygon(data = neg1To1 , aes(x = x , y = y) , fill = "gray80") + geom_polygon(data = lessThanNeg2 , aes(x = x , y = y) , fill = "gray40") + geom_polygon(data = moreThanPos2 , aes(x = x , y = y) , fill = "gray40") + p
p + geom_polygon(data = neg2To2 , aes(x = x , y = y) , fill = "gray60") + geom_polygon(data = neg1To1 , aes(x = x , y = y) , fill = "gray80") + geom_polygon(data = lessThanNeg2 , aes(x = x , y = y) , fill = "gray40") + geom_polygon(data = moreThanPos2 , aes(x = x , y = y) , fill = "gray40")
randNorm <- rnorm(30000)
randDensity <- dnorm(randNorm)
p <- ggplot(data.frame(x = randNorm , y = randDensity)) + aes(x = x , y = y) + geom_line() + labs(x = "x" , y = "確玁EE")
p
neg2Seq <- seq(from = min(randNorm) , to = -2 , by = .1)
lessThanNeg2 <- data.frame(x = neg2Seq , y = dnorm(neg2Seq))
lessThanNeg2 <- rbind(c(min(randNorm) , 0 ) , lessThanNeg2 , c(max(lessThanNeg2$x) , 0))
p + geom_polygon(data = lessThanNeg2 , aes(x = x , y = y) , fill = "gray50")
neg1Pos1Seq <- seq(from = -1 , to = 1 , by = .1)
neg1To1 <- data.frame(x = neg1Pos1Seq , y = dnorm(neg1Pos1Seq))
neg1To1 <- rbind(c(min(neg1To1$x) , 0 ) , neg1To1 , c(max(neg1To1$x) , 0))
Pos2Seq <- seq(from = 2 , to = max(randNorm) , by = .1)
moreThanPos2 <- data.frame(x = Pos2Seq , y = dnorm(Pos2Seq))
moreThanPos2 <- rbind(c(min(moreThanPos2$x) , 0 ) , moreThanPos2 , c(max(randNorm) , 0))
p + geom_polygon(data = neg2To2 , aes(x = x , y = y) , fill = "gray60") + geom_polygon(data = neg1To1 , aes(x = x , y = y) , fill = "gray80") + geom_polygon(data = lessThanNeg2 , aes(x = x , y = y) , fill = "gray40") + geom_polygon(data = moreThanPos2 , aes(x = x , y = y) , fill = "gray40")
neg2Pos2Seq <- seq(from = -2 , to = 2 , by = .1)
neg2To2 <- data.frame(x = neg2Pos2Seq , y = dnorm(neg2Pos2Seq))
neg2To2 <- rbind(c(min(neg2To2$x) , 0 ) , neg2To2 , c(max(neg2To2$x) , 0))
p + geom_polygon(data = neg2To2 , aes(x = x , y = y) , fill = "gray60") + geom_polygon(data = neg1To1 , aes(x = x , y = y) , fill = "gray80") + geom_polygon(data = lessThanNeg2 , aes(x = x , y = y) , fill = "gray40") + geom_polygon(data = moreThanPos2 , aes(x = x , y = y) , fill = "gray40")
p + geom_density(aes(x = x) , fill = "gray40") + + geom_polygon(data = neg2To2 , aes(x = x , y = y) , fill = "gray60") + geom_polygon(data = neg1To1 , aes(x = x , y = y) , fill = "gray80")
p + geom_density(aes(x = x) , fill = "gray40")
p + geom_density(aes(x = x , y = y) , fill = "gray40")
p + geom_polygon(data = neg2To2 , aes(x = x , y = y) , fill = "gray60") + geom_polygon(data = neg1To1 , aes(x = x , y = y) , fill = "gray80")
p + geom_polygon(data = neg2To2 , aes(x = x , y = y) , fill = "gray60") + geom_polygon(data = neg1To1 , aes(x = x , y = y) , fill = "gray80") + geom_polygon(data = lessThanNeg2 , aes(x = x , y = y) , fill = "gray40") + geom_polygon(data = moreThanPos2 , aes(x = x , y = y) , fill = "gray40")
randNorm <- rnorm(30000)
randDensity <- dnorm(randNorm)
p <- ggplot(data.frame(x = randNorm , y = randDensity)) + aes(x = x , y = y) + geom_line() + labs(x = "x" , y = "確玁EE")
neg1Pos1Seq <- seq(from = -1 , to = 1 , by = .1)
neg1To1 <- data.frame(x = neg1Pos1Seq , y = dnorm(neg1Pos1Seq))
neg1To1 <- rbind(c(min(neg1To1$x) , 0 ) , neg1To1 , c(max(neg1To1$x) , 0))
neg2Pos2Seq <- seq(from = -2 , to = 2 , by = .1)
neg2To2 <- data.frame(x = neg2Pos2Seq , y = dnorm(neg2Pos2Seq))
neg2To2 <- rbind(c(min(neg2To2$x) , 0 ) , neg2To2 , c(max(neg2To2$x) , 0))
neg2Seq <- seq(from = min(randNorm) , to = -2 , by = .1)
lessThanNeg2 <- data.frame(x = neg2Seq , y = dnorm(neg2Seq))
lessThanNeg2 <- rbind(c(min(randNorm) , 0 ) , lessThanNeg2 , c(max(lessThanNeg2$x) , 0))
Pos2Seq <- seq(from = 2 , to = max(randNorm) , by = .1)
moreThanPos2 <- data.frame(x = Pos2Seq , y = dnorm(Pos2Seq))
moreThanPos2 <- rbind(c(min(moreThanPos2$x) , 0 ) , moreThanPos2 , c(max(randNorm) , 0))
p + geom_polygon(data = neg2To2 , aes(x = x , y = y) , fill = "gray60") + geom_polygon(data = neg1To1 , aes(x = x , y = y) , fill = "gray80") + geom_polygon(data = lessThanNeg2 , aes(x = x , y = y) , fill = "gray40") + geom_polygon(data = moreThanPos2 , aes(x = x , y = y) , fill = "gray40")
randNorm <- rnorm(30000)
randDensity <- dnorm(randNorm)
p <- ggplot(data.frame(x = randNorm , y = randDensity)) + aes(x = x , y = y) + geom_line() + labs(x = "x" , y = "確玁EE")
neg1Pos1Seq <- seq(from = -1 , to = 1 , by = .1)
neg1To1 <- data.frame(x = neg1Pos1Seq , y = dnorm(neg1Pos1Seq))
neg1To1 <- rbind(c(min(neg1To1$x) , 0 ) , neg1To1 , c(max(neg1To1$x) , 0))
neg2Pos2Seq <- seq(from = -2 , to = 2 , by = .1)
neg2To2 <- data.frame(x = neg2Pos2Seq , y = dnorm(neg2Pos2Seq))
neg2To2 <- rbind(c(min(neg2To2$x) , 0 ) , neg2To2 , c(max(neg2To2$x) , 0))
neg2Seq <- seq(from = min(randNorm) , to = -1.98 , by = .1)
lessThanNeg2 <- data.frame(x = neg2Seq , y = dnorm(neg2Seq))
lessThanNeg2 <- rbind(c(min(randNorm) , 0 ) , lessThanNeg2 , c(max(lessThanNeg2$x) , 0))
Pos2Seq <- seq(from = 2 , to = max(randNorm) , by = .1)
moreThanPos2 <- data.frame(x = Pos2Seq , y = dnorm(Pos2Seq))
moreThanPos2 <- rbind(c(min(moreThanPos2$x) , 0 ) , moreThanPos2 , c(max(randNorm) , 0))
p + geom_polygon(data = neg2To2 , aes(x = x , y = y) , fill = "gray60") + geom_polygon(data = neg1To1 , aes(x = x , y = y) , fill = "gray80") + geom_polygon(data = lessThanNeg2 , aes(x = x , y = y) , fill = "gray40") + geom_polygon(data = moreThanPos2 , aes(x = x , y = y) , fill = "gray40")
randNorm <- rnorm(30000)
randDensity <- dnorm(randNorm)
p <- ggplot(data.frame(x = randNorm , y = randDensity)) + aes(x = x , y = y) + geom_line() + labs(x = "x" , y = "確玁EE")
neg1Pos1Seq <- seq(from = -1 , to = 1 , by = .1)
neg1To1 <- data.frame(x = neg1Pos1Seq , y = dnorm(neg1Pos1Seq))
neg1To1 <- rbind(c(min(neg1To1$x) , 0 ) , neg1To1 , c(max(neg1To1$x) , 0))
neg2Pos2Seq <- seq(from = -2 , to = 2 , by = .1)
neg2To2 <- data.frame(x = neg2Pos2Seq , y = dnorm(neg2Pos2Seq))
neg2To2 <- rbind(c(min(neg2To2$x) , 0 ) , neg2To2 , c(max(neg2To2$x) , 0))
neg2Seq <- seq(from = min(randNorm) , to = -1.96 , by = .1)
lessThanNeg2 <- data.frame(x = neg2Seq , y = dnorm(neg2Seq))
lessThanNeg2 <- rbind(c(min(randNorm) , 0 ) , lessThanNeg2 , c(max(lessThanNeg2$x) , 0))
Pos2Seq <- seq(from = 2 , to = max(randNorm) , by = .1)
moreThanPos2 <- data.frame(x = Pos2Seq , y = dnorm(Pos2Seq))
moreThanPos2 <- rbind(c(min(moreThanPos2$x) , 0 ) , moreThanPos2 , c(max(randNorm) , 0))
p + geom_polygon(data = neg2To2 , aes(x = x , y = y) , fill = "gray60") + geom_polygon(data = neg1To1 , aes(x = x , y = y) , fill = "gray80") + geom_polygon(data = lessThanNeg2 , aes(x = x , y = y) , fill = "gray40") + geom_polygon(data = moreThanPos2 , aes(x = x , y = y) , fill = "gray40")
randNorm <- rnorm(30000)
randDensity <- dnorm(randNorm)
p <- ggplot(data.frame(x = randNorm , y = randDensity)) + aes(x = x , y = y) + geom_line() + labs(x = "x" , y = "確玁EE")
neg1Pos1Seq <- seq(from = -1 , to = 1 , by = .1)
neg1To1 <- data.frame(x = neg1Pos1Seq , y = dnorm(neg1Pos1Seq))
neg1To1 <- rbind(c(min(neg1To1$x) , 0 ) , neg1To1 , c(max(neg1To1$x) , 0))
neg2Pos2Seq <- seq(from = -2.02 , to = 2 , by = .1)
neg2To2 <- data.frame(x = neg2Pos2Seq , y = dnorm(neg2Pos2Seq))
neg2To2 <- rbind(c(min(neg2To2$x) , 0 ) , neg2To2 , c(max(neg2To2$x) , 0))
neg2Seq <- seq(from = min(randNorm) , to = -2 , by = .1)
lessThanNeg2 <- data.frame(x = neg2Seq , y = dnorm(neg2Seq))
lessThanNeg2 <- rbind(c(min(randNorm) , 0 ) , lessThanNeg2 , c(max(lessThanNeg2$x) , 0))
Pos2Seq <- seq(from = 2 , to = max(randNorm) , by = .1)
moreThanPos2 <- data.frame(x = Pos2Seq , y = dnorm(Pos2Seq))
moreThanPos2 <- rbind(c(min(moreThanPos2$x) , 0 ) , moreThanPos2 , c(max(randNorm) , 0))
p + geom_polygon(data = neg2To2 , aes(x = x , y = y) , fill = "gray60") + geom_polygon(data = neg1To1 , aes(x = x , y = y) , fill = "gray80") + geom_polygon(data = lessThanNeg2 , aes(x = x , y = y) , fill = "gray40") + geom_polygon(data = moreThanPos2 , aes(x = x , y = y) , fill = "gray40")
randNorm <- rnorm(30000)
randDensity <- dnorm(randNorm)
p <- ggplot(data.frame(x = randNorm , y = randDensity)) + aes(x = x , y = y) + geom_line() + labs(x = "x" , y = "確玁EE")
neg1Pos1Seq <- seq(from = -1 , to = 1 , by = .1)
neg1To1 <- data.frame(x = neg1Pos1Seq , y = dnorm(neg1Pos1Seq))
neg1To1 <- rbind(c(min(neg1To1$x) , 0 ) , neg1To1 , c(max(neg1To1$x) , 0))
neg2Pos2Seq <- seq(from = -2.02 , to = 2.02 , by = .1)
neg2To2 <- data.frame(x = neg2Pos2Seq , y = dnorm(neg2Pos2Seq))
neg2To2 <- rbind(c(min(neg2To2$x) , 0 ) , neg2To2 , c(max(neg2To2$x) , 0))
neg2Seq <- seq(from = min(randNorm) , to = -2 , by = .1)
lessThanNeg2 <- data.frame(x = neg2Seq , y = dnorm(neg2Seq))
lessThanNeg2 <- rbind(c(min(randNorm) , 0 ) , lessThanNeg2 , c(max(lessThanNeg2$x) , 0))
Pos2Seq <- seq(from = 2 , to = max(randNorm) , by = .1)
moreThanPos2 <- data.frame(x = Pos2Seq , y = dnorm(Pos2Seq))
moreThanPos2 <- rbind(c(min(moreThanPos2$x) , 0 ) , moreThanPos2 , c(max(randNorm) , 0))
p + geom_polygon(data = neg2To2 , aes(x = x , y = y) , fill = "gray60") + geom_polygon(data = neg1To1 , aes(x = x , y = y) , fill = "gray80") + geom_polygon(data = lessThanNeg2 , aes(x = x , y = y) , fill = "gray40") + geom_polygon(data = moreThanPos2 , aes(x = x , y = y) , fill = "gray40")
randNorm <- rnorm(30000)
randDensity <- dnorm(randNorm)
p <- ggplot(data.frame(x = randNorm , y = randDensity)) + aes(x = x , y = y) + geom_line() + labs(x = "x" , y = "確玁EE")
neg1Pos1Seq <- seq(from = -1 , to = 1 , by = .1)
neg1To1 <- data.frame(x = neg1Pos1Seq , y = dnorm(neg1Pos1Seq))
neg1To1 <- rbind(c(min(neg1To1$x) , 0 ) , neg1To1 , c(max(neg1To1$x) , 0))
neg2Pos2Seq <- seq(from = -1.99 , to = 1.99 , by = .1)
neg2To2 <- data.frame(x = neg2Pos2Seq , y = dnorm(neg2Pos2Seq))
neg2To2 <- rbind(c(min(neg2To2$x) , 0 ) , neg2To2 , c(max(neg2To2$x) , 0))
neg2Seq <- seq(from = min(randNorm) , to = -2 , by = .1)
lessThanNeg2 <- data.frame(x = neg2Seq , y = dnorm(neg2Seq))
lessThanNeg2 <- rbind(c(min(randNorm) , 0 ) , lessThanNeg2 , c(max(lessThanNeg2$x) , 0))
Pos2Seq <- seq(from = 2 , to = max(randNorm) , by = .1)
moreThanPos2 <- data.frame(x = Pos2Seq , y = dnorm(Pos2Seq))
moreThanPos2 <- rbind(c(min(moreThanPos2$x) , 0 ) , moreThanPos2 , c(max(randNorm) , 0))
p + geom_polygon(data = neg2To2 , aes(x = x , y = y) , fill = "gray60") + geom_polygon(data = neg1To1 , aes(x = x , y = y) , fill = "gray80") + geom_polygon(data = lessThanNeg2 , aes(x = x , y = y) , fill = "gray40") + geom_polygon(data = moreThanPos2 , aes(x = x , y = y) , fill = "gray40")
randNorm <- rnorm(30000)
randDensity <- dnorm(randNorm)
p <- ggplot(data.frame(x = randNorm , y = randDensity)) + aes(x = x , y = y) + geom_line() + labs(x = "x" , y = "確玁EE")
neg1Pos1Seq <- seq(from = -1 , to = 1 , by = .1)
neg1To1 <- data.frame(x = neg1Pos1Seq , y = dnorm(neg1Pos1Seq))
neg1To1 <- rbind(c(min(neg1To1$x) , 0 ) , neg1To1 , c(max(neg1To1$x) , 0))
neg2Pos2Seq <- seq(from = -2 , to = 2 , by = .1)
neg2To2 <- data.frame(x = neg2Pos2Seq , y = dnorm(neg2Pos2Seq))
neg2To2 <- rbind(c(min(neg2To2$x) , 0 ) , neg2To2 , c(max(neg2To2$x) , 0))
neg2Seq <- seq(from = min(randNorm) , to = -2 , by = .1)
lessThanNeg2 <- data.frame(x = neg2Seq , y = dnorm(neg2Seq))
lessThanNeg2 <- rbind(c(min(randNorm) , 0 ) , lessThanNeg2 , c(max(lessThanNeg2$x) , 0))
Pos2Seq <- seq(from = 2 , to = max(randNorm) , by = .1)
moreThanPos2 <- data.frame(x = Pos2Seq , y = dnorm(Pos2Seq))
moreThanPos2 <- rbind(c(min(moreThanPos2$x) , 0 ) , moreThanPos2 , c(max(randNorm) , 0))
p + geom_polygon(data = neg2To2 , aes(x = x , y = y) , fill = "gray60") + geom_polygon(data = neg1To1 , aes(x = x , y = y) , fill = "gray80") + geom_polygon(data = lessThanNeg2 , aes(x = x , y = y) , fill = "gray40") + geom_polygon(data = moreThanPos2 , aes(x = x , y = y) , fill = "gray40")
randNorm <- rnorm(30000)
randDensity <- dnorm(randNorm)
p <- ggplot(data.frame(x = randNorm , y = randDensity)) + aes(x = x , y = y) + geom_line() + labs(x = "x" , y = "確玁EE")
neg1Pos1Seq <- seq(from = -1 , to = 1 , by = .1)
neg1To1 <- data.frame(x = neg1Pos1Seq , y = dnorm(neg1Pos1Seq))
neg1To1 <- rbind(c(min(neg1To1$x) , 0 ) , neg1To1 , c(max(neg1To1$x) , 0))
neg2Pos2Seq <- seq(from = -2 , to = 2 , by = .1)
neg2To2 <- data.frame(x = neg2Pos2Seq , y = dnorm(neg2Pos2Seq))
neg2To2 <- rbind(c(min(neg2To2$x) , 0 ) , neg2To2 , c(max(neg2To2$x) , 0))
neg2Seq <- seq(from = min(randNorm) , to = -1.99 , by = .1)
lessThanNeg2 <- data.frame(x = neg2Seq , y = dnorm(neg2Seq))
lessThanNeg2 <- rbind(c(min(randNorm) , 0 ) , lessThanNeg2 , c(max(lessThanNeg2$x) , 0))
Pos2Seq <- seq(from = 2 , to = max(randNorm) , by = .1)
moreThanPos2 <- data.frame(x = Pos2Seq , y = dnorm(Pos2Seq))
moreThanPos2 <- rbind(c(min(moreThanPos2$x) , 0 ) , moreThanPos2 , c(max(randNorm) , 0))
p + geom_polygon(data = neg2To2 , aes(x = x , y = y) , fill = "gray60") + geom_polygon(data = neg1To1 , aes(x = x , y = y) , fill = "gray80") + geom_polygon(data = lessThanNeg2 , aes(x = x , y = y) , fill = "gray40") + geom_polygon(data = moreThanPos2 , aes(x = x , y = y) , fill = "gray40")
randNorm <- rnorm(30000)
randDensity <- dnorm(randNorm)
p <- ggplot(data.frame(x = randNorm , y = randDensity)) + aes(x = x , y = y) + geom_line() + labs(x = "x" , y = "確玁EE")
neg1Pos1Seq <- seq(from = -1 , to = 1 , by = .1)
neg1To1 <- data.frame(x = neg1Pos1Seq , y = dnorm(neg1Pos1Seq))
neg1To1 <- rbind(c(min(neg1To1$x) , 0 ) , neg1To1 , c(max(neg1To1$x) , 0))
neg2Pos2Seq <- seq(from = -2 , to = 2 , by = .1)
neg2To2 <- data.frame(x = neg2Pos2Seq , y = dnorm(neg2Pos2Seq))
neg2To2 <- rbind(c(min(neg2To2$x) , 0 ) , neg2To2 , c(max(neg2To2$x) , 0))
neg2Seq <- seq(from = min(randNorm) , to = -1.98 , by = .1)
lessThanNeg2 <- data.frame(x = neg2Seq , y = dnorm(neg2Seq))
lessThanNeg2 <- rbind(c(min(randNorm) , 0 ) , lessThanNeg2 , c(max(lessThanNeg2$x) , 0))
Pos2Seq <- seq(from = 2 , to = max(randNorm) , by = .1)
moreThanPos2 <- data.frame(x = Pos2Seq , y = dnorm(Pos2Seq))
moreThanPos2 <- rbind(c(min(moreThanPos2$x) , 0 ) , moreThanPos2 , c(max(randNorm) , 0))
p + geom_polygon(data = neg2To2 , aes(x = x , y = y) , fill = "gray60") + geom_polygon(data = neg1To1 , aes(x = x , y = y) , fill = "gray80") + geom_polygon(data = lessThanNeg2 , aes(x = x , y = y) , fill = "gray40") + geom_polygon(data = moreThanPos2 , aes(x = x , y = y) , fill = "gray40")
randNorm <- rnorm(30000)
randDensity <- dnorm(randNorm)
p <- ggplot(data.frame(x = randNorm , y = randDensity)) + aes(x = x , y = y) + geom_line() + labs(x = "x" , y = "確玁EE")
neg1Pos1Seq <- seq(from = -1 , to = 1 , by = .1)
neg1To1 <- data.frame(x = neg1Pos1Seq , y = dnorm(neg1Pos1Seq))
neg1To1 <- rbind(c(min(neg1To1$x) , 0 ) , neg1To1 , c(max(neg1To1$x) , 0))
neg2Pos2Seq <- seq(from = -2 , to = 2 , by = .1)
neg2To2 <- data.frame(x = neg2Pos2Seq , y = dnorm(neg2Pos2Seq))
neg2To2 <- rbind(c(min(neg2To2$x) , 0 ) , neg2To2 , c(max(neg2To2$x) , 0))
neg2Seq <- seq(from = min(randNorm) , to = -1.96 , by = .1)
lessThanNeg2 <- data.frame(x = neg2Seq , y = dnorm(neg2Seq))
lessThanNeg2 <- rbind(c(min(randNorm) , 0 ) , lessThanNeg2 , c(max(lessThanNeg2$x) , 0))
Pos2Seq <- seq(from = 2 , to = max(randNorm) , by = .1)
moreThanPos2 <- data.frame(x = Pos2Seq , y = dnorm(Pos2Seq))
moreThanPos2 <- rbind(c(min(moreThanPos2$x) , 0 ) , moreThanPos2 , c(max(randNorm) , 0))
p + geom_polygon(data = neg2To2 , aes(x = x , y = y) , fill = "gray60") + geom_polygon(data = neg1To1 , aes(x = x , y = y) , fill = "gray80") + geom_polygon(data = lessThanNeg2 , aes(x = x , y = y) , fill = "gray40") + geom_polygon(data = moreThanPos2 , aes(x = x , y = y) , fill = "gray40")
randNorm <- rnorm(30000)
randDensity <- dnorm(randNorm)
p <- ggplot(data.frame(x = randNorm , y = randDensity)) + aes(x = x , y = y) + geom_line() + labs(x = "x" , y = "確玁EE")
neg1Pos1Seq <- seq(from = -1 , to = 1 , by = .1)
neg1To1 <- data.frame(x = neg1Pos1Seq , y = dnorm(neg1Pos1Seq))
neg1To1 <- rbind(c(min(neg1To1$x) , 0 ) , neg1To1 , c(max(neg1To1$x) , 0))
neg2Pos2Seq <- seq(from = -2 , to = 2 , by = .1)
neg2To2 <- data.frame(x = neg2Pos2Seq , y = dnorm(neg2Pos2Seq))
neg2To2 <- rbind(c(min(neg2To2$x) , 0 ) , neg2To2 , c(max(neg2To2$x) , 0))
neg2Seq <- seq(from = min(randNorm) , to = -1.97 , by = .1)
lessThanNeg2 <- data.frame(x = neg2Seq , y = dnorm(neg2Seq))
lessThanNeg2 <- rbind(c(min(randNorm) , 0 ) , lessThanNeg2 , c(max(lessThanNeg2$x) , 0))
Pos2Seq <- seq(from = 2 , to = max(randNorm) , by = .1)
moreThanPos2 <- data.frame(x = Pos2Seq , y = dnorm(Pos2Seq))
moreThanPos2 <- rbind(c(min(moreThanPos2$x) , 0 ) , moreThanPos2 , c(max(randNorm) , 0))
p + geom_polygon(data = neg2To2 , aes(x = x , y = y) , fill = "gray60") + geom_polygon(data = neg1To1 , aes(x = x , y = y) , fill = "gray80") + geom_polygon(data = lessThanNeg2 , aes(x = x , y = y) , fill = "gray40") + geom_polygon(data = moreThanPos2 , aes(x = x , y = y) , fill = "gray40")
randNorm <- rnorm(30000)
randDensity <- dnorm(randNorm)
p <- ggplot(data.frame(x = randNorm , y = randDensity)) + aes(x = x , y = y) + geom_line() + labs(x = "x" , y = "確玁EE")
neg1Pos1Seq <- seq(from = -1 , to = 1 , by = .1)
neg1To1 <- data.frame(x = neg1Pos1Seq , y = dnorm(neg1Pos1Seq))
neg1To1 <- rbind(c(min(neg1To1$x) , 0 ) , neg1To1 , c(max(neg1To1$x) , 0))
neg2Pos2Seq <- seq(from = -2 , to = 2 , by = .1)
neg2To2 <- data.frame(x = neg2Pos2Seq , y = dnorm(neg2Pos2Seq))
neg2To2 <- rbind(c(min(neg2To2$x) , 0 ) , neg2To2 , c(max(neg2To2$x) , 0))
neg2Seq <- seq(from = min(randNorm) , to = -1.98 , by = .1)
lessThanNeg2 <- data.frame(x = neg2Seq , y = dnorm(neg2Seq))
lessThanNeg2 <- rbind(c(min(randNorm) , 0 ) , lessThanNeg2 , c(max(lessThanNeg2$x) , 0))
Pos2Seq <- seq(from = 2 , to = max(randNorm) , by = .1)
moreThanPos2 <- data.frame(x = Pos2Seq , y = dnorm(Pos2Seq))
moreThanPos2 <- rbind(c(min(moreThanPos2$x) , 0 ) , moreThanPos2 , c(max(randNorm) , 0))
p + geom_polygon(data = neg2To2 , aes(x = x , y = y) , fill = "gray60") + geom_polygon(data = neg1To1 , aes(x = x , y = y) , fill = "gray80") + geom_polygon(data = lessThanNeg2 , aes(x = x , y = y) , fill = "gray40") + geom_polygon(data = moreThanPos2 , aes(x = x , y = y) , fill = "gray40")
randNorm <- rnorm(30000)
randDensity <- dnorm(randNorm)
p <- ggplot(data.frame(x = randNorm , y = randDensity)) + aes(x = x , y = y) + geom_line() + labs(x = "x" , y = "確玁EE")
neg1Pos1Seq <- seq(from = -1 , to = 1 , by = .1)
neg1To1 <- data.frame(x = neg1Pos1Seq , y = dnorm(neg1Pos1Seq))
neg1To1 <- rbind(c(min(neg1To1$x) , 0 ) , neg1To1 , c(max(neg1To1$x) , 0))
neg2Pos2Seq <- seq(from = -2 , to = 2 , by = .1)
neg2To2 <- data.frame(x = neg2Pos2Seq , y = dnorm(neg2Pos2Seq))
neg2To2 <- rbind(c(min(neg2To2$x) , 0 ) , neg2To2 , c(max(neg2To2$x) , 0))
neg2Seq <- seq(from = min(randNorm) , to = -1.99 , by = .1)
lessThanNeg2 <- data.frame(x = neg2Seq , y = dnorm(neg2Seq))
lessThanNeg2 <- rbind(c(min(randNorm) , 0 ) , lessThanNeg2 , c(max(lessThanNeg2$x) , 0))
Pos2Seq <- seq(from = 2 , to = max(randNorm) , by = .1)
moreThanPos2 <- data.frame(x = Pos2Seq , y = dnorm(Pos2Seq))
moreThanPos2 <- rbind(c(min(moreThanPos2$x) , 0 ) , moreThanPos2 , c(max(randNorm) , 0))
p + geom_polygon(data = neg2To2 , aes(x = x , y = y) , fill = "gray60") + geom_polygon(data = neg1To1 , aes(x = x , y = y) , fill = "gray80") + geom_polygon(data = lessThanNeg2 , aes(x = x , y = y) , fill = "gray40") + geom_polygon(data = moreThanPos2 , aes(x = x , y = y) , fill = "gray40")
randNorm <- rnorm(30000)
randDensity <- dnorm(randNorm)
p <- ggplot(data.frame(x = randNorm , y = randDensity)) + aes(x = x , y = y) + geom_line() + labs(x = "x" , y = "確玁EE")
neg1Pos1Seq <- seq(from = -1 , to = 1 , by = .1)
neg1To1 <- data.frame(x = neg1Pos1Seq , y = dnorm(neg1Pos1Seq))
neg1To1 <- rbind(c(min(neg1To1$x) , 0 ) , neg1To1 , c(max(neg1To1$x) , 0))
neg2Pos2Seq <- seq(from = -2 , to = 2 , by = .1)
neg2To2 <- data.frame(x = neg2Pos2Seq , y = dnorm(neg2Pos2Seq))
neg2To2 <- rbind(c(min(neg2To2$x) , 0 ) , neg2To2 , c(max(neg2To2$x) , 0))
neg2Seq <- seq(from = min(randNorm) , to = -2 , by = .1)
lessThanNeg2 <- data.frame(x = neg2Seq , y = dnorm(neg2Seq))
lessThanNeg2 <- rbind(c(min(randNorm) , 0 ) , lessThanNeg2 , c(max(lessThanNeg2$x) , 0))
Pos2Seq <- seq(from = 2 , to = max(randNorm) , by = .1)
moreThanPos2 <- data.frame(x = Pos2Seq , y = dnorm(Pos2Seq))
moreThanPos2 <- rbind(c(min(moreThanPos2$x) , 0 ) , moreThanPos2 , c(max(randNorm) , 0))
p + geom_polygon(data = neg2To2 , aes(x = x , y = y) , fill = "gray60") + geom_polygon(data = neg1To1 , aes(x = x , y = y) , fill = "gray80") + geom_polygon(data = lessThanNeg2 , aes(x = x , y = y) , fill = "gray40") + geom_polygon(data = moreThanPos2 , aes(x = x , y = y) , fill = "gray40")
randNorm <- rnorm(30000)
randDensity <- dnorm(randNorm)
p <- ggplot(data.frame(x = randNorm , y = randDensity)) + aes(x = x , y = y) + geom_line() + labs(x = "x" , y = "確玁EE")
neg1Pos1Seq <- seq(from = -1 , to = 1 , by = .1)
neg1To1 <- data.frame(x = neg1Pos1Seq , y = dnorm(neg1Pos1Seq))
neg1To1 <- rbind(c(min(neg1To1$x) , 0 ) , neg1To1 , c(max(neg1To1$x) , 0))
neg2Pos2Seq <- seq(from = -2 , to = 2 , by = .1)
neg2To2 <- data.frame(x = neg2Pos2Seq , y = dnorm(neg2Pos2Seq))
neg2To2 <- rbind(c(min(neg2To2$x) , 0 ) , neg2To2 , c(max(neg2To2$x) , 0))
neg2Seq <- seq(from = min(randNorm) , to = -2 , by = .1)
lessThanNeg2 <- data.frame(x = neg2Seq , y = dnorm(neg2Seq))
lessThanNeg2 <- rbind(c(min(randNorm) , 0 ) , lessThanNeg2 , c(max(lessThanNeg2$x) , 0))
Pos2Seq <- seq(from = 2 , to = max(randNorm) , by = .1)
moreThanPos2 <- data.frame(x = Pos2Seq , y = dnorm(Pos2Seq))
moreThanPos2 <- rbind(c(min(moreThanPos2$x) , 0 ) , moreThanPos2 , c(max(randNorm) , 0))
p + geom_polygon(data = neg2To2 , aes(x = x , y = y) , fill = "gray60") + geom_polygon(data = neg1To1 , aes(x = x , y = y) , fill = "gray80") + geom_polygon(data = lessThanNeg2 , aes(x = x , y = y) , fill = "gray40") + geom_polygon(data = moreThanPos2 , aes(x = x , y = y) , fill = "gray40")
text( -2, 0.08, "-2ρE )
text( -1, 0.28, "-1ρE )
text(  1, 0.28, "+1ρE )
text(  2, 0.08, "+2ρE )
1 + 2 + 3 + 4 + 5
sum(1:1000)
1:1000
1 + 2 + 3 + 4 + 5
sum(1:1000)
1:1000
birthwt <- load(file.choose())
head(birthwt)
birthwt
load(file.choose())
head(birthwt)
bw.glm <- birthwt %>% glm(low ~ age + lwt + race + smoke + ptl + ht + ui + ftv, data = .,family = binomial)
library(dplyr)
bw.glm <- birthwt %>% glm(low ~ age + lwt + race + smoke + ptl + ht + ui + ftv, data = .,family = binomial)
bw.glm %>% summary
bw.glm$coefficients %>% exp %>%  round(2)
q()
setwd("~/R/Detectives-master/AmosWIN")
dat <- read.csv (Chapter03/sample.csv)
setwd("~/R/Detectives-master/AmosWIN/Chapter03")
dat <- read.csv (sample.csv)
dat <- read.csv (file.choose())# AmosWIN/Chapter03/sample.csvを選択する
dat <- read.csv (Chapter03/sample.csv)
dat <- read.csv ("Chapter03/sample.csv")
setwd("~/R/Detectives-master/AmosWIN")
dat <- read.csv ("Chapter03/sample.csv")
# vers. 1.0
menus <- read.csv("Chapter04/menus.csv", stringsAsFactors =  FALSE, colClasses = c("factor","Date","numeric"))
library (dplyr)
dat %>% table
chisq.test (dat2)
dat2 <-  dat %>% table
chisq.test (dat2)
survey <- read.csv("Chapter03/survey.csv")
survey %>% head # head (survey) に同じ
head (survey)
ggplot(survey, aes (x = 立場, y = 回答6, fill = 回答6 )) + geom_bar(stat="identity")
table1 %>% as.data.frame %>% ggplot(aes (x = 立場, y = Freq, fill = 回答6 )) + geom_bar(stat="identity") + ylab ("人数")
table1 <- survey  %>% select (立場, 回答6) %>% table
table1 %>% as.data.frame %>% ggplot(aes (x = 立場, y = Freq, fill = 回答6 )) + geom_bar(stat="identity") + ylab ("人数")
# ggplot(table1, aes (x = 立場, y = 回答6, fill = 回答6 )) + geom_bar(stat="identity")
ggplot(table1, aes (x = 立場, y = 回答6, fill = 回答6 )) + geom_bar(stat="identity")
# ggplot(survey, aes (x = 立場, y = 回答6, fill = 回答6 )) + geom_bar(stat="identity")
ggplot(survey, aes (x = 立場, y = 回答6, fill = 回答6 )) + geom_bar(stat="identity")
table1 %>% as.data.frame %>% ggplot(aes (x = 立場, y = Freq, fill = 回答6 )) + geom_bar(stat="identity") + ylab ("人数")
