library(datasets)
data("swiss")
View(swiss)
head(swiss)
## Fertility Agriculture Examination Education Catholic
## Courtelary 80.2 17.0 15 12 9.96
## Delemont 83.1 45.1 6 9 84.84
## Franches-Mnt 92.5 39.7 5 5 93.40
## Moutier 85.8 36.5 12 7 33.77
## Neuveville 76.9 43.5 17 15 5.16
## Porrentruy 76.1 35.3 9 7 90.57
## Infant.Mortality
## Courtelary 22.2
## Delemont 22.2
## Franches-Mnt 20.2
## Moutier 20.3
## Neuveville 20.6
## Porrentruy 26.6
summary(swiss)
## Fertility Agriculture Examination Education
## Min. :35.00 Min. : 1.20 Min. : 3.00 Min. : 1.00
## 1st Qu.:64.70 1st Qu.:35.90 1st Qu.:12.00 1st Qu.: 6.00
## Median :70.40 Median :54.10 Median :16.00 Median : 8.00
## Mean :70.14 Mean :50.66 Mean :16.49 Mean :10.98
## 3rd Qu.:78.45 3rd Qu.:67.65 3rd Qu.:22.00 3rd Qu.:12.00
## Max. :92.50 Max. :89.70 Max. :37.00 Max. :53.00
## Catholic Infant.Mortality
## Min. : 2.150 Min. :10.80
## 1st Qu.: 5.195 1st Qu.:18.15
## Median : 15.140 Median :20.00
## Mean : 41.144 Mean :19.94
## 3rd Qu.: 93.125 3rd Qu.:21.70
## Max. :100.000 Max. :26.60
plot(swiss$Fertility)
cor.test(swiss$Fertility,swiss$Infant.Mortality)
##
## Pearson's product-moment correlation
##
## data: swiss$Fertility and swiss$Infant.Mortality
## t = 3.0737, df = 45, p-value = 0.003585
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
## 0.1469699 0.6285366
## sample estimates:
## cor
## 0.416556
plot(swiss$Fertility,swiss$Infant.Mortality)
plot(swiss$Education,swiss$Infant.Mortality)
## R Markdown
summary(cars)
## speed dist
## Min. : 4.0 Min. : 2.00
## 1st Qu.:12.0 1st Qu.: 26.00
## Median :15.0 Median : 36.00
## Mean :15.4 Mean : 42.98
## 3rd Qu.:19.0 3rd Qu.: 56.00
## Max. :25.0 Max. :120.00
You can also embed plots, for example:
library(corrplot)
## corrplot 0.92 loaded
plot(swiss$Fertility)
cor.test(swiss$Fertility,swiss$Infant.Mortality)
##
## Pearson's product-moment correlation
##
## data: swiss$Fertility and swiss$Infant.Mortality
## t = 3.0737, df = 45, p-value = 0.003585
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
## 0.1469699 0.6285366
## sample estimates:
## cor
## 0.416556
plot(swiss$Fertility,swiss$Infant.Mortality)
plot(swiss$Education,swiss$Infant.Mortality)