rguiのコンソールからRpubsにアップロードできた件
お陰様
iris
R source
knitr::opts_chunk$set(tidy = TRUE, warning=FALSE)
irisてっなに?
中身は?(表)
R source
knitr::kable(head(iris), caption = "head(iris)")
head(iris)
5.1
3.5
1.4
0.2
setosa
4.9
3.0
1.4
0.2
setosa
4.7
3.2
1.3
0.2
setosa
4.6
3.1
1.5
0.2
setosa
5.0
3.6
1.4
0.2
setosa
5.4
3.9
1.7
0.4
setosa
R source
library(formattable)
formattable::formattable(head(iris))
Sepal.Length
Sepal.Width
Petal.Length
Petal.Width
Species
5.1
3.5
1.4
0.2
setosa
4.9
3.0
1.4
0.2
setosa
4.7
3.2
1.3
0.2
setosa
4.6
3.1
1.5
0.2
setosa
5.0
3.6
1.4
0.2
setosa
5.4
3.9
1.7
0.4
setosa
R source
formattable::formattable(head(iris), list(Sepal.Length = color_bar("tomato"), Sepal.Width = color_bar("steelblue"), Petal.Length = color_bar("olivedrab"),
Petal.Width = color_bar("orange")))
Sepal.Length
Sepal.Width
Petal.Length
Petal.Width
Species
5.1
3.5
1.4
0.2
setosa
4.9
3.0
1.4
0.2
setosa
4.7
3.2
1.3
0.2
setosa
4.6
3.1
1.5
0.2
setosa
5.0
3.6
1.4
0.2
setosa
5.4
3.9
1.7
0.4
setosa
構造は?
R source
str(iris)
R output
## 'data.frame': 150 obs. of 5 variables:
## $ Sepal.Length: num 5.1 4.9 4.7 4.6 5 5.4 4.6 5 4.4 4.9 ...
## $ Sepal.Width : num 3.5 3 3.2 3.1 3.6 3.9 3.4 3.4 2.9 3.1 ...
## $ Petal.Length: num 1.4 1.4 1.3 1.5 1.4 1.7 1.4 1.5 1.4 1.5 ...
## $ Petal.Width : num 0.2 0.2 0.2 0.2 0.2 0.4 0.3 0.2 0.2 0.1 ...
## $ Species : Factor w/ 3 levels "setosa","versicolor",..: 1 1 1 1 1 1 1 1 1 1 ...
サマリー
R source
summary(iris)
R output
## Sepal.Length Sepal.Width Petal.Length Petal.Width Species
## Min. :4.300 Min. :2.000 Min. :1.000 Min. :0.100 setosa :50
## 1st Qu.:5.100 1st Qu.:2.800 1st Qu.:1.600 1st Qu.:0.300 versicolor:50
## Median :5.800 Median :3.000 Median :4.350 Median :1.300 virginica :50
## Mean :5.843 Mean :3.057 Mean :3.758 Mean :1.199
## 3rd Qu.:6.400 3rd Qu.:3.300 3rd Qu.:5.100 3rd Qu.:1.800
## Max. :7.900 Max. :4.400 Max. :6.900 Max. :2.500
箱ひげ図
Whisker Plots
R source
boxplot(iris[, 1] ~ iris[, 5], lwd = 2)
ヒストグラム
R source
a <- iris[1:50, 1]
b <- iris[51:100, 1]
c <- iris[101:150, 1]
hist(c, col = 3, add = F, freq = F)
rug(c, col = 3)
hist(b, col = 2, add = T, freq = F)
rug(b, col = 2)
hist(a, col = 1, add = T, freq = F)
rug(a, col = 1)
lines(density(iris[, 1]), col = 4, lwd = 2)
R source
## stem
stem(iris[, 1])
R output
##
## The decimal point is 1 digit(s) to the left of the |
##
## 42 | 0
## 44 | 0000
## 46 | 000000
## 48 | 00000000000
## 50 | 0000000000000000000
## 52 | 00000
## 54 | 0000000000000
## 56 | 00000000000000
## 58 | 0000000000
## 60 | 000000000000
## 62 | 0000000000000
## 64 | 000000000000
## 66 | 0000000000
## 68 | 0000000
## 70 | 00
## 72 | 0000
## 74 | 0
## 76 | 00000
## 78 | 0
円グラフ
R source
pie(table(iris[, 5]), col = rainbow(3))
棒グラフ
R source
barplot(tapply(iris[, 1], iris[, 5], mean), col = rainbow(3))
R source
barplot(table(iris[, 5], iris[, 2]), col = rainbow(3))
stripchart
R source
stripchart(iris[, 1] ~ iris[, 5], col = rainbow(3), pch = 8)
pairs
R source
pairs(iris[, -5], col = rainbow(3)[iris[, 5]], pch = 19)
heatmap
R source
heatmap(as.matrix(iris[, -5]), cexCol = 0.7)
樹形図
R source
plot(hclust(dist(iris[, -5]), "ave"))