Latihan penggunaan RMarkdown ini menggunakan salah satu “datasets” yang tersedia di R, yaitu swiss. Data swiss merupakan informasi hasil pengukuran fertilitas standar dan indikator sosial ekonomi dari setiap 47 provinsi yang masyarakatnya berbahasa Perancis pada tahun 1888. Adapun sumber deskripsi data dapat diakses melalui link berikut: https://stat.ethz.ch/R-manual/R-devel/library/datasets/html/swiss.html.
For more details on using R Markdown see http://rmarkdown.rstudio.com.
When you click the Knit button a document will be generated that includes both content as well as the output of any embedded R code chunks within the document. You can embed an R code chunk like this:
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
Berdasarkan hasil analisis data swiss
library(corrplot)
## corrplot 0.92 loaded
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)
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)
lmswiss = lm(swiss$Infant.Mortality~swiss$Fertility,
data=swiss)
summary(lmswiss)
##
## Call:
## lm(formula = swiss$Infant.Mortality ~ swiss$Fertility, data = swiss)
##
## Residuals:
## Min 1Q Median 3Q Max
## -7.6038 -1.5673 -0.0607 1.8367 6.0788
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 13.12970 2.25063 5.834 5.51e-07 ***
## swiss$Fertility 0.09713 0.03160 3.074 0.00359 **
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 2.677 on 45 degrees of freedom
## Multiple R-squared: 0.1735, Adjusted R-squared: 0.1552
## F-statistic: 9.448 on 1 and 45 DF, p-value: 0.003585
Note that the echo = FALSE parameter was added to the
code chunk to prevent printing of the R code that generated the
plot.