This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 練習問題 | |
# 1. | |
Ctable <- xtabs(Freq ~ management + own, data = JobSatisfaction) | |
# (a) | |
chisq.test(Ctable) | |
# (b) | |
fisher.test(Ctable) | |
# 2. | |
Ctable <- xtabs(Freq ~ Sex + Survived, data = Titanic[,,"Child",]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 練習問題 | |
# 1. | |
Titan <- data.frame(Titanic) | |
res <- glm(Survived ~ Class + Sex + Age, weights = Freq, | |
family = binomial, data = Titan) | |
res | |
summary(res) | |
exp(res$coefficients) | |
mosaicplot(Titanic, color = TRUE) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 練習問題 | |
# (a) | |
x <- c(314, 39, 78, 105, 77, 93, 140, 69) | |
pref <- c("A福岡", "B佐賀", "C長崎", "D熊本", | |
"E大分", "F宮崎", "G鹿児島", "H沖縄") | |
result <- glm(x ~ pref, family = poisson) | |
pred <- predict(result, type = "terms", | |
se.fit = TRUE) | |
ggplot(data.frame(pref, pred$fit), aes(x = pref, y = pred$fit)) + | |
geom_bar(stat = "identity") + |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 練習問題 | |
# 1. | |
JointSports | |
result <- loglm(Freq ~ opinion * year * grade * gender, data = JointSports) | |
step(result) | |
step(result, k = log(sum(JointSports$Freq))) | |
mosaicplot(xtabs(Freq ~ year + grade + gender + opinion, data = JointSports)) | |
# 2. | |
# (a) | |
tabledata <- xtabs(Freq ~ sex + method2 + age.group, data = Suicide) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 1. | |
data("JointSports") | |
result <- ctree(opinion ~ year + grade + gender, data = JointSports, | |
weights = Freq) | |
plot(result) | |
# 2. | |
titan.d <- data.frame(Titanic) | |
head(titan.d) | |
result <- ctree(Survived ~ Class + Sex + Age, weights = Freq, | |
data = titan.d) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
p <- ggplot(mpg, aes(displ, hwy)) + | |
geom_point() + | |
facet_wrap(~drv) + | |
theme_bw() + | |
theme(panel.grid = element_blank()) + | |
geom_smooth(method = "lm") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(ggplot2) | |
library(dplyr) | |
# hwy : highway miles per gallon | |
# 1mile == 1.60934km | |
# 1gallon == 3.78541L | |
# ∴ mile / gallon = 1.60934 / 3.78541 km / L | |
mpg2kpl <- function(x) x * 1.60934 / 3.78541 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
runner: | |
scopes: | |
python: "python3" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(sf) | |
# 日本地図のシェープファイルを読み込む | |
f <- "N03-160101_GML/N03-16_160101.shp" | |
japan <- st_read(f) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
lazy fmaps -u='https?://reader\.aol\.co\.jp/.*' gh gs gd ga go gx ? r = - f u j k <Space> <S-Space> t v <Return> m 1 2 3 4 5 / | |
lazy fmaps -u='https?://reader\.aol\.co\.jp/.*' -events=vkeydown J K N P X O A |