diff --git a/melissa-polonenko/rmarkdown/challenge.Rmd b/melissa-polonenko/rmarkdown/challenge.Rmd new file mode 100644 index 0000000..c3ca5d8 --- /dev/null +++ b/melissa-polonenko/rmarkdown/challenge.Rmd @@ -0,0 +1,71 @@ +--- +title: "RMarkdown Challenge" +author: "Melissa Polonenko" +date: "Monday, November 23, 2015" +output: + html_document: + toc: true + fig_caption: true + number_section: true + word_document: + toc: true + fig_caption: true + +--- + +```{r,echo=FALSE, warning=FALSE, message=FALSE} +# Prepare +knitr::opts_chunk$set(echo=FALSE, warning=FALSE) +setwd("C:/Users/Melissa/Desktop/practice-2015-10/melissa-polonenko/rmarkdown") + + +library(pander) +library(captioner) +library(dplyr) +library(tidyr) +library(ggplot2) + +df<- as.data.frame(state.x77)%>% + add_rownames() %>% + tbl_df() + +# Table and figure numbers/captions +tabNums <- captioner(prefix='Table') +figNums <- captioner(prefix='Figure') +income_illit_cap <- figNums('in_il_Fig','Illiteracy by Income for each of the US states') + +``` + +# Brief Description + +In the `state.x77` dataset there are: + +- `r dim(df)[1]` rows, each row specifying a US state +- `r dim(df[-1])[2]` variables, which include: `r names(df[-1])` + +The population across these `r dim(df)[1]` states averages `r mean(df$Population) %>% round(0)` +/- `r sd(df$Population) %>% round(0)` (SD). + +# Plots + +```{r,fig.cap=income_illit_cap, dpi=300} +df %>% + ggplot(aes(x=Income, y=Illiteracy))+ + geom_point(size=2)+ + theme_bw()+ + labs(x="Income", y="Illiteracy") +``` + +# Tables +```{r,results='asis'} +df %>% + select(-rowname) %>% + gather(Measure,Value) %>% + group_by(Measure) %>% + summarise(Means=mean(Value) %>% round(1), + SD=sd(Value) %>% round(1)) %>% + pander(caption=tabNums('tab1','Summary of Statistics for the USA')) +``` + +```{r, eval=FALSE} +rmarkdown::render('challenge.Rmd', c('word_document', 'html_document')) +``` diff --git a/melissa-polonenko/rmarkdown/challenge.docx b/melissa-polonenko/rmarkdown/challenge.docx new file mode 100644 index 0000000..d874c08 Binary files /dev/null and b/melissa-polonenko/rmarkdown/challenge.docx differ diff --git a/melissa-polonenko/rmarkdown/challenge.html b/melissa-polonenko/rmarkdown/challenge.html new file mode 100644 index 0000000..48a14c4 --- /dev/null +++ b/melissa-polonenko/rmarkdown/challenge.html @@ -0,0 +1,176 @@ + + + + +
+ + + + + + + + +In the state.x77
dataset there are:
The population across these 50 states averages 4246 +/- 4464 (SD).
+Measure | +Means | +SD | +
---|---|---|
Population | +4246 | +4464 | +
Income | +4436 | +614.5 | +
Illiteracy | +1.2 | +0.6 | +
Life Exp | +70.9 | +1.3 | +
Murder | +7.4 | +3.7 | +
HS Grad | +53.1 | +8.1 | +
Frost | +104.5 | +52 | +
Area | +70736 | +85327 | +
# title: "RMarkdown Practice"
+# author: "Melissa Polonenko"
+# date: "Monday, November 23, 2015"
+# bibliography: /home/melissa/bibliography/bib.bib
+# csl: location of the csl file (style for references; can get in citation-style-language on github - get a clone or copy)
+# output:
+# html_document:
+# fig_caption: true
+# toc: true
+
+# @Giacca2011a versus [@Giacco2011a;@Matthews1985]
++ | 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 | +
+ | Estimate | +Std. Error | +t value | +Pr(>|t|) | +
---|---|---|---|---|
dist | +0.1656 | +0.01749 | +9.464 | +1.49e-12 | +
(Intercept) | +8.284 | +0.8744 | +9.474 | +1.441e-12 | +
Reference to Table 1. The text within “`” that starts with “r” will run that code and replace it here. Otherwise, without the “r” you will just print the code.
+Compare 42.98 with mean(car$dist)
.
Measure | +Means | +
---|---|
speed | +15.4 | +
dist | +42.98 | +
For a list: (need a space after to generate the list)
+cars
cars
This is a quote:
+++To be or not to be
+
You can also embed plots, for example:
+Note that the echo = FALSE
parameter was added to the code chunk to prevent printing of the R code that generated the plot.