galaaz 0.4.10 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +2048 -531
- data/Rakefile +3 -2
- data/bin/gknit +152 -6
- data/bin/gknit-draft +105 -0
- data/bin/gknit-draft.rb +28 -0
- data/bin/gknit_Rscript +127 -0
- data/bin/grun +27 -1
- data/bin/gstudio +47 -4
- data/bin/{gstudio.rb → gstudio_irb.rb} +0 -0
- data/bin/gstudio_pry.rb +7 -0
- data/blogs/galaaz_ggplot/galaaz_ggplot.html +10 -195
- data/blogs/galaaz_ggplot/galaaz_ggplot.md +404 -0
- data/blogs/galaaz_ggplot/galaaz_ggplot_files/figure-html/midwest_rb.png +0 -0
- data/blogs/galaaz_ggplot/galaaz_ggplot_files/figure-html/scatter_plot_rb.png +0 -0
- data/blogs/gknit/gknit.Rmd +5 -3
- data/blogs/gknit/gknit.pdf +0 -0
- data/blogs/gknit/lst.rds +0 -0
- data/blogs/manual/lst.rds +0 -0
- data/blogs/manual/manual.Rmd +826 -53
- data/blogs/manual/manual.html +2338 -695
- data/blogs/manual/manual.md +2032 -539
- data/blogs/manual/manual.pdf +0 -0
- data/blogs/manual/manual.tex +1804 -594
- data/blogs/manual/manual_files/figure-html/bubble-1.png +0 -0
- data/blogs/manual/manual_files/figure-html/diverging_bar.png +0 -0
- data/blogs/manual/manual_files/figure-latex/bubble-1.png +0 -0
- data/blogs/manual/manual_files/figure-latex/diverging_bar.pdf +0 -0
- data/blogs/manual/model.rb +41 -0
- data/blogs/nse_dplyr/nse_dplyr.Rmd +226 -73
- data/blogs/nse_dplyr/nse_dplyr.html +254 -336
- data/blogs/nse_dplyr/nse_dplyr.md +353 -158
- data/blogs/oh_my/oh_my.html +274 -386
- data/blogs/oh_my/oh_my.md +208 -205
- data/blogs/ruby_plot/ruby_plot.html +20 -205
- data/blogs/ruby_plot/ruby_plot.md +14 -15
- data/blogs/ruby_plot/ruby_plot_files/figure-html/dose_len.png +0 -0
- data/blogs/ruby_plot/ruby_plot_files/figure-html/facet_by_delivery.png +0 -0
- data/blogs/ruby_plot/ruby_plot_files/figure-html/facet_by_dose.png +0 -0
- data/blogs/ruby_plot/ruby_plot_files/figure-html/facets_by_delivery_color.png +0 -0
- data/blogs/ruby_plot/ruby_plot_files/figure-html/facets_by_delivery_color2.png +0 -0
- data/blogs/ruby_plot/ruby_plot_files/figure-html/facets_with_decorations.png +0 -0
- data/blogs/ruby_plot/ruby_plot_files/figure-html/facets_with_jitter.png +0 -0
- data/blogs/ruby_plot/ruby_plot_files/figure-html/facets_with_points.png +0 -0
- data/blogs/ruby_plot/ruby_plot_files/figure-html/final_box_plot.png +0 -0
- data/blogs/ruby_plot/ruby_plot_files/figure-html/final_violin_plot.png +0 -0
- data/blogs/ruby_plot/ruby_plot_files/figure-html/violin_with_jitter.png +0 -0
- data/examples/Bibliography/master.bib +50 -0
- data/examples/Bibliography/stats.bib +72 -0
- data/examples/islr/x_y_rnorm.jpg +0 -0
- data/examples/latex_templates/Test-acm_article/Makefile +16 -0
- data/examples/latex_templates/Test-acm_article/Test-acm_article.Rmd +65 -0
- data/examples/latex_templates/Test-acm_article/acm_proc_article-sp.cls +1670 -0
- data/examples/latex_templates/Test-acm_article/sensys-abstract.cls +703 -0
- data/examples/latex_templates/Test-acm_article/sigproc.bib +59 -0
- data/examples/latex_templates/Test-acs_article/Test-acs_article.Rmd +260 -0
- data/examples/latex_templates/Test-acs_article/Test-acs_article.pdf +0 -0
- data/examples/latex_templates/Test-acs_article/acs-Test-acs_article.bib +11 -0
- data/examples/latex_templates/Test-acs_article/acs-my_output.bib +11 -0
- data/examples/latex_templates/Test-acs_article/acstest.bib +17 -0
- data/examples/latex_templates/Test-aea_article/AEA.cls +1414 -0
- data/{blogs/gknit/marshal.dump → examples/latex_templates/Test-aea_article/BibFile.bib} +0 -0
- data/examples/latex_templates/Test-aea_article/Test-aea_article.Rmd +108 -0
- data/examples/latex_templates/Test-aea_article/Test-aea_article.pdf +0 -0
- data/examples/latex_templates/Test-aea_article/aea.bst +1269 -0
- data/examples/latex_templates/Test-aea_article/multicol.sty +853 -0
- data/examples/latex_templates/Test-aea_article/references.bib +0 -0
- data/examples/latex_templates/Test-aea_article/setspace.sty +546 -0
- data/examples/latex_templates/Test-amq_article/Test-amq_article.Rmd +256 -0
- data/examples/latex_templates/Test-amq_article/Test-amq_article.pdf +0 -0
- data/examples/latex_templates/Test-amq_article/Test-amq_article.pdfsync +3397 -0
- data/examples/latex_templates/Test-amq_article/pics/Figure2.pdf +0 -0
- data/examples/latex_templates/Test-ams_article/Test-ams_article.Rmd +215 -0
- data/examples/latex_templates/Test-ams_article/amstest.bib +436 -0
- data/examples/latex_templates/Test-asa_article/Test-asa_article.Rmd +153 -0
- data/examples/latex_templates/Test-asa_article/Test-asa_article.pdf +0 -0
- data/examples/latex_templates/Test-asa_article/agsm.bst +1353 -0
- data/examples/latex_templates/Test-asa_article/bibliography.bib +233 -0
- data/examples/latex_templates/Test-ieee_article/IEEEtran.bst +2409 -0
- data/examples/latex_templates/Test-ieee_article/IEEEtran.cls +6346 -0
- data/examples/latex_templates/Test-ieee_article/Test-ieee_article.Rmd +175 -0
- data/examples/latex_templates/Test-ieee_article/Test-ieee_article.pdf +0 -0
- data/examples/latex_templates/Test-ieee_article/mybibfile.bib +20 -0
- data/examples/latex_templates/Test-rjournal_article/RJournal.sty +335 -0
- data/examples/latex_templates/Test-rjournal_article/RJreferences.bib +18 -0
- data/examples/latex_templates/Test-rjournal_article/RJwrapper.pdf +0 -0
- data/examples/latex_templates/Test-rjournal_article/Test-rjournal_article.Rmd +52 -0
- data/examples/latex_templates/Test-springer_article/Test-springer_article.Rmd +65 -0
- data/examples/latex_templates/Test-springer_article/Test-springer_article.pdf +0 -0
- data/examples/latex_templates/Test-springer_article/bibliography.bib +26 -0
- data/examples/latex_templates/Test-springer_article/spbasic.bst +1658 -0
- data/examples/latex_templates/Test-springer_article/spmpsci.bst +1512 -0
- data/examples/latex_templates/Test-springer_article/spphys.bst +1443 -0
- data/examples/latex_templates/Test-springer_article/svglov3.clo +113 -0
- data/examples/latex_templates/Test-springer_article/svjour3.cls +1431 -0
- data/examples/rmarkdown/svm-rmarkdown-anon-ms-example/svm-rmarkdown-anon-ms-example.Rmd +73 -0
- data/examples/rmarkdown/svm-rmarkdown-anon-ms-example/svm-rmarkdown-anon-ms-example.pdf +0 -0
- data/examples/rmarkdown/svm-rmarkdown-article-example/svm-rmarkdown-article-example.Rmd +382 -0
- data/examples/rmarkdown/svm-rmarkdown-article-example/svm-rmarkdown-article-example.pdf +0 -0
- data/examples/rmarkdown/svm-rmarkdown-beamer-example/svm-rmarkdown-beamer-example.Rmd +164 -0
- data/examples/rmarkdown/svm-rmarkdown-beamer-example/svm-rmarkdown-beamer-example.pdf +0 -0
- data/examples/rmarkdown/svm-rmarkdown-cv/svm-rmarkdown-cv.Rmd +92 -0
- data/examples/rmarkdown/svm-rmarkdown-cv/svm-rmarkdown-cv.pdf +0 -0
- data/examples/rmarkdown/svm-rmarkdown-syllabus-example/attend-grade-relationships.csv +482 -0
- data/examples/rmarkdown/svm-rmarkdown-syllabus-example/svm-rmarkdown-syllabus-example.Rmd +280 -0
- data/examples/rmarkdown/svm-rmarkdown-syllabus-example/svm-rmarkdown-syllabus-example.pdf +0 -0
- data/examples/rmarkdown/svm-xaringan-example/svm-xaringan-example.Rmd +386 -0
- data/lib/R_interface/r.rb +1 -1
- data/lib/R_interface/r_libs.R +1 -1
- data/lib/R_interface/r_methods.rb +10 -0
- data/lib/R_interface/rpkg.rb +1 -0
- data/lib/R_interface/rsupport.rb +4 -6
- data/lib/gknit.rb +2 -0
- data/lib/gknit/draft.rb +105 -0
- data/lib/gknit/knitr_engine.rb +0 -33
- data/lib/util/exec_ruby.rb +1 -27
- data/specs/figures/bg.jpeg +0 -0
- data/specs/figures/bg.png +0 -0
- data/specs/figures/dose_len.png +0 -0
- data/specs/figures/no_args.jpeg +0 -0
- data/specs/figures/no_args.png +0 -0
- data/specs/figures/width_height.jpeg +0 -0
- data/specs/figures/width_height.png +0 -0
- data/specs/figures/width_height_units1.jpeg +0 -0
- data/specs/figures/width_height_units1.png +0 -0
- data/specs/figures/width_height_units2.jpeg +0 -0
- data/specs/figures/width_height_units2.png +0 -0
- data/specs/r_dataframe.spec.rb +11 -11
- data/specs/ruby_expression.spec.rb +1 -0
- data/specs/tmp.rb +41 -20
- data/version.rb +1 -1
- metadata +73 -35
- data/blogs/galaaz_ggplot/galaaz_ggplot.aux +0 -41
- data/blogs/galaaz_ggplot/galaaz_ggplot.out +0 -10
- data/blogs/galaaz_ggplot/galaaz_ggplot_files/figure-latex/midwest_rb.pdf +0 -0
- data/blogs/galaaz_ggplot/galaaz_ggplot_files/figure-latex/scatter_plot_rb.pdf +0 -0
- data/blogs/gknit/gknit.md +0 -1430
- data/blogs/gknit/gknit.tex +0 -1358
- data/blogs/manual/graph.rb +0 -29
- data/blogs/nse_dplyr/nse_dplyr.tex +0 -1373
- data/blogs/ruby_plot/ruby_plot.Rmd_external_figs +0 -662
- data/blogs/ruby_plot/ruby_plot_files/figure-html/dose_len.svg +0 -57
- data/blogs/ruby_plot/ruby_plot_files/figure-html/facet_by_delivery.svg +0 -106
- data/blogs/ruby_plot/ruby_plot_files/figure-html/facet_by_dose.svg +0 -110
- data/blogs/ruby_plot/ruby_plot_files/figure-html/facets_by_delivery_color.svg +0 -174
- data/blogs/ruby_plot/ruby_plot_files/figure-html/facets_by_delivery_color2.svg +0 -236
- data/blogs/ruby_plot/ruby_plot_files/figure-html/facets_with_jitter.svg +0 -296
- data/blogs/ruby_plot/ruby_plot_files/figure-html/facets_with_points.svg +0 -236
- data/blogs/ruby_plot/ruby_plot_files/figure-html/final_box_plot.svg +0 -218
- data/blogs/ruby_plot/ruby_plot_files/figure-html/final_violin_plot.svg +0 -128
- data/blogs/ruby_plot/ruby_plot_files/figure-html/violin_with_jitter.svg +0 -150
- data/blogs/ruby_plot/ruby_plot_files/figure-latex/dose_len.png +0 -0
- data/blogs/ruby_plot/ruby_plot_files/figure-latex/facet_by_delivery.png +0 -0
- data/blogs/ruby_plot/ruby_plot_files/figure-latex/facet_by_dose.png +0 -0
- data/blogs/ruby_plot/ruby_plot_files/figure-latex/facets_by_delivery_color.png +0 -0
- data/blogs/ruby_plot/ruby_plot_files/figure-latex/facets_by_delivery_color2.png +0 -0
- data/blogs/ruby_plot/ruby_plot_files/figure-latex/facets_with_decorations.png +0 -0
- data/blogs/ruby_plot/ruby_plot_files/figure-latex/facets_with_jitter.png +0 -0
- data/blogs/ruby_plot/ruby_plot_files/figure-latex/facets_with_points.png +0 -0
- data/blogs/ruby_plot/ruby_plot_files/figure-latex/final_box_plot.png +0 -0
- data/blogs/ruby_plot/ruby_plot_files/figure-latex/final_violin_plot.png +0 -0
- data/blogs/ruby_plot/ruby_plot_files/figure-latex/violin_with_jitter.png +0 -0
- data/examples/paper/paper.rb +0 -36
@@ -0,0 +1,73 @@
|
|
1
|
+
---
|
2
|
+
output:
|
3
|
+
pdf_document:
|
4
|
+
citation_package: natbib
|
5
|
+
keep_tex: true
|
6
|
+
fig_caption: true
|
7
|
+
latex_engine: pdflatex
|
8
|
+
template: ~/desenv/galaaz/sty/svm-r-markdown-templates/svm-latex-anon-ms.tex
|
9
|
+
title: "An Example Title with a Really Long Title: Also a Subtitle"
|
10
|
+
runhead: "A Running Head"
|
11
|
+
thanks: "Replication files are available on the author's Github account (http://github.com/svmiller).
|
12
|
+
**Current version**: `r format(Sys.time(), '%B %d, %Y')`;
|
13
|
+
**Corresponding author**: svmille@clemson.edu."
|
14
|
+
author:
|
15
|
+
- name: Steven V. Miller
|
16
|
+
affiliation: Clemson University
|
17
|
+
abstract: "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin fermentum blandit felis.
|
18
|
+
Nam consequat ultricies porta. Phasellus aliquet metus quis enim aliquet, id suscipit justo mollis.
|
19
|
+
Vivamus dapibus erat a urna hendrerit, eu bibendum risus pretium. Praesent sit amet elementum augue,
|
20
|
+
ac iaculis eros. Praesent sollicitudin pulvinar tellus ac fermentum. Integer porttitor vestibulum orci,
|
21
|
+
id hendrerit turpis fringilla eu. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices
|
22
|
+
posuere cubilia Curae; Pellentesque sit amet pellentesque odio. Nam vitae lacinia tellus. Phasellus
|
23
|
+
sit amet metus vel ipsum efficitur viverra. Nullam malesuada libero eu justo egestas efficitur.
|
24
|
+
Proin eu elit ut dolor egestas consequat. Maecenas pretium, purus aliquet finibus pellentesque,
|
25
|
+
mauris eros tempor magna, eget dignissim magna ligula accumsan erat. Etiam."
|
26
|
+
keywords: "pandoc, r markdown, knitr"
|
27
|
+
date: "`r format(Sys.time(), '%B %d, %Y')`"
|
28
|
+
geometry: margin=1in
|
29
|
+
fontfamily: mathpazo
|
30
|
+
fontsize: 11pt
|
31
|
+
bibliography: /home/rbotafogo/desenv/galaaz/examples/Bibliography/master.bib
|
32
|
+
biblio-style: apsr
|
33
|
+
indent: yes
|
34
|
+
colorlinks: true
|
35
|
+
---
|
36
|
+
|
37
|
+
# Introduction
|
38
|
+
|
39
|
+
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer nec felis placerat, suscipit risus eget, condimentum ex. Nunc laoreet mi nisi, eu volutpat orci porttitor at. Nunc a bibendum diam. Aenean condimentum, neque at gravida imperdiet, orci arcu laoreet risus, eu gravida erat leo et ante. Suspendisse tempor non eros nec vestibulum. Morbi cursus posuere nunc, semper dignissim mi lacinia non. Nunc sagittis ipsum in mattis volutpat. Morbi in mauris ut urna rhoncus pellentesque. Morbi hendrerit sodales metus, at placerat velit bibendum at. Etiam ut est id ligula hendrerit commodo et eget lorem. See my previous scholarship [@miller2013tdpi; @miller2016ieea; @miller2016etst].
|
40
|
+
|
41
|
+
Proin vitae metus at turpis aliquet pulvinar. Suspendisse potenti. Interdum et malesuada fames ac ante ipsum primis in faucibus. Etiam tincidunt euismod mauris, pulvinar scelerisque nulla accumsan et. Praesent tempus ipsum varius enim eleifend, ut blandit arcu molestie. Vestibulum tempor est blandit ligula porta consequat. Praesent condimentum auctor ligula, ac pellentesque ante fringilla egestas. Praesent accumsan scelerisque eros nec mattis. Donec eget aliquet metus. Sed auctor, lacus mollis hendrerit lobortis, nisl felis vehicula libero, sed aliquet elit augue et eros.
|
42
|
+
|
43
|
+
Etiam molestie augue ut dui vulputate, quis tempor augue pharetra. Pellentesque ac mauris eget nulla vestibulum ultrices. Sed hendrerit in tortor vitae aliquet. Sed vehicula pharetra interdum. Duis eget interdum diam, eget lacinia nunc. Duis viverra maximus euismod. Nulla interdum diam ac nisl laoreet sodales. Sed commodo diam ut massa gravida, id viverra neque semper. Vivamus vitae nibh suscipit, viverra mi convallis, posuere orci. Sed nec tempus dolor, ac facilisis quam. Aenean id diam semper leo pharetra elementum id eget justo.
|
44
|
+
|
45
|
+
# The Next Section
|
46
|
+
|
47
|
+
Praesent a sagittis elit, et ornare augue. Sed non urna non elit convallis faucibus eu non ante. Vivamus placerat, lorem nec porttitor ornare, dolor sapien ullamcorper nulla, vitae tempus nunc erat vel leo. Nunc non felis in tortor scelerisque venenatis. Sed nec nulla interdum, vulputate velit at, fringilla justo. Maecenas maximus volutpat mi, eu placerat augue gravida at. Vestibulum ut luctus eros, sed faucibus purus. Suspendisse scelerisque commodo gravida. Fusce tincidunt turpis ut sapien pulvinar sollicitudin. Donec ut fringilla augue. Integer semper pharetra gravida. Aenean eros justo, sodales id tincidunt ac, vulputate id mauris. In a laoreet nisi. Praesent in elit at ex dignissim consectetur. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Ut rhoncus eget purus ac feugiat.
|
48
|
+
|
49
|
+
## A Subsection
|
50
|
+
|
51
|
+
Vestibulum efficitur finibus malesuada. Proin a tristique turpis, ut pellentesque ante. Aliquam auctor auctor dolor. Suspendisse porttitor mi eros, sed ultricies erat pharetra tincidunt. Duis molestie quis nunc ac tristique. Aenean placerat malesuada sollicitudin. Sed ac lacus orci. Morbi iaculis diam eu nulla pellentesque laoreet. Praesent quis congue libero, id gravida velit.
|
52
|
+
|
53
|
+
Morbi fringilla rhoncus vestibulum. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Quisque pulvinar lorem non odio posuere egestas. Phasellus quam libero, varius sed augue non, aliquet ultricies massa. Etiam posuere purus mi, ac aliquet est iaculis a. Mauris sollicitudin, ipsum id pellentesque vehicula, dui ipsum euismod ipsum, non bibendum orci augue ac quam. Phasellus elementum neque ac tempor tincidunt. Cras et diam eu nisl imperdiet gravida. Nunc nec dolor mi. Donec congue viverra lacus, eu auctor est laoreet in. Phasellus aliquam odio mi, at posuere dui venenatis in. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas.
|
54
|
+
|
55
|
+
Fusce iaculis nulla sit amet mauris hendrerit, in tempor dui posuere. Interdum et malesuada fames ac ante ipsum primis in faucibus. In pretium justo tellus, eu pulvinar sem gravida sit amet. Vestibulum malesuada lorem ut ante cursus condimentum. Cras vitae porta tellus, vel tempor purus. Mauris ut elit in nulla semper ultricies. Donec ultricies leo eu feugiat dictum. Vivamus lobortis, velit hendrerit ultrices accumsan, metus diam venenatis magna, sed pellentesque dui mi ut sapien. Maecenas lacinia, ante vel aliquam gravida, quam sem lacinia erat, nec egestas turpis quam id dolor. Integer et semper velit. Nam sed ipsum purus. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Nunc aliquam efficitur purus, et facilisis erat scelerisque ut. Phasellus suscipit a eros vehicula laoreet. In in mi quis elit scelerisque elementum.
|
56
|
+
|
57
|
+
Nullam ac libero id nunc imperdiet posuere eget non eros. Curabitur sit amet nibh a ipsum faucibus aliquam. Duis eget dui non velit cursus vulputate. Proin pulvinar sit amet turpis vitae congue. Praesent bibendum tempor porta. Maecenas porttitor purus at dolor maximus, vel varius est blandit. Aenean mi tortor, eleifend non malesuada sed, viverra nec felis. Phasellus ac urna dignissim, euismod est nec, tristique arcu. Integer et interdum turpis, sit amet cursus enim. Aliquam pulvinar laoreet imperdiet.
|
58
|
+
|
59
|
+
Mauris a nisl condimentum, molestie sem nec, eleifend tortor. Phasellus consectetur augue nulla, vel dignissim massa interdum a. Sed feugiat fermentum porttitor. Phasellus vitae erat sit amet diam vestibulum porta. Morbi consequat magna ligula, vel pellentesque mi euismod rutrum. Ut id ligula aliquam, feugiat orci id, cursus nunc. Quisque pellentesque tristique risus non pharetra. Phasellus eget venenatis velit. Aliquam non neque non orci varius auctor id vitae lorem. Donec ac est non libero faucibus ultrices. Morbi id neque tortor. Nulla faucibus dui vitae ante hendrerit, sed elementum diam molestie.
|
60
|
+
|
61
|
+
Ut mollis fermentum lacinia. Cras at aliquam dui. Fusce eu nulla porta urna consectetur gravida. In molestie in lacus ut tincidunt. Maecenas blandit efficitur lacus, sit amet laoreet erat. Proin at interdum mi. Donec eleifend vestibulum pharetra. Aliquam aliquet turpis non ultrices rhoncus. Nam vestibulum leo id ipsum cursus varius. Suspendisse potenti.
|
62
|
+
|
63
|
+
|
64
|
+
\newpage
|
65
|
+
|
66
|
+
<!--
|
67
|
+
# References
|
68
|
+
\setlength{\parindent}{-0.2in}
|
69
|
+
\setlength{\leftskip}{0.2in}
|
70
|
+
\setlength{\parskip}{8pt}
|
71
|
+
\vspace*{-0.2in}
|
72
|
+
\noindent
|
73
|
+
-->
|
Binary file
|
@@ -0,0 +1,382 @@
|
|
1
|
+
---
|
2
|
+
output:
|
3
|
+
pdf_document:
|
4
|
+
citation_package: natbib
|
5
|
+
keep_tex: true
|
6
|
+
fig_caption: true
|
7
|
+
latex_engine: pdflatex
|
8
|
+
template: ~/desenv/galaaz/sty/svm-r-markdown-templates/svm-latex-ms.tex
|
9
|
+
title: "A Pandoc Markdown Article Starter and Template"
|
10
|
+
thanks: "Replication files are available on the author's Github account (http://github.com/svmiller). **Current version**: `r format(Sys.time(), '%B %d, %Y')`; **Corresponding author**: svmille@clemson.edu."
|
11
|
+
author:
|
12
|
+
- name: Steven V. Miller
|
13
|
+
affiliation: Clemson University
|
14
|
+
abstract: "This document provides an introduction to R Markdown, argues for its benefits, and presents a sample manuscript template intended for an academic audience. I include basic syntax to R Markdown and a minimal working example of how the analysis itself can be conducted within R with the `knitr` package."
|
15
|
+
keywords: "pandoc, r markdown, knitr"
|
16
|
+
date: "`r format(Sys.time(), '%B %d, %Y')`"
|
17
|
+
geometry: margin=1in
|
18
|
+
fontfamily: mathpazo
|
19
|
+
fontsize: 11pt
|
20
|
+
# spacing: double
|
21
|
+
bibliography: /home/rbotafogo/desenv/galaaz/examples/Bibliography/master.bib
|
22
|
+
endnote: no
|
23
|
+
---
|
24
|
+
|
25
|
+
# Introduction
|
26
|
+
|
27
|
+
Academic workflow, certainly in political science, is at a crossroads. The *American Journal
|
28
|
+
of Political Science* (*AJPS*) announced a (my words)
|
29
|
+
["show your work" initiative](http://ajps.org/2015/03/26/the-ajps-replication-policy-innovations-and-revisions/) in which authors who are tentatively accepted for publication at the journal
|
30
|
+
must hand over the raw code and data that produced the results shown in the manuscript. The
|
31
|
+
editorial team at *AJPS* then reproduces the code from the manuscript. Pending successful
|
32
|
+
replication, the manuscript moves toward publication. The *AJPS* might be at the fore of this
|
33
|
+
movement, and it could be the most aggressive among political science journals, but other
|
34
|
+
journals in our field have signed the joint [Data Access & Research Transparency](http://www.dartstatement.org/) (DART) initiative. This, at a bare minimum, requires uploading code from
|
35
|
+
quantitatively-oriented published articles to in-house directories hosted by the journal or
|
36
|
+
to services like [Dataverse](http://dataverse.org/).
|
37
|
+
|
38
|
+
There are workflow implications to the Lacour controversy as well. Political science, for
|
39
|
+
the foreseeable future, will struggle with the extent of
|
40
|
+
[the data fraud perpetrated by Michael Lacour](http://stanford.edu/~dbroock/broockman_kalla_aronow_lg_irregularities.pdf) in an article co-authored with Donald P. Green in *Science*, the general
|
41
|
+
scientific journal of record in the United States. A failure to reproduce LaCour's results
|
42
|
+
with different samples uncovered a comprehensive effort by LaCour to "fake" data that provided
|
43
|
+
results to what we felt or believed to be true [(i.e. "truthiness")](http://chronicle.com/article/LAffaire-LaCour/230905/). However, [fake data can have real consequences](http://kieranhealy.org/blog/archives/2015/05/20/fake-science-real-consequences/) for both the researcher and those who want to
|
44
|
+
learn from it and use it for various purposes. Even research done honestly may suffer the same
|
45
|
+
fate if researchers are not diligent in their workflow.
|
46
|
+
|
47
|
+
These recent events underscore the DART push and cast a shadow over our workflow. However, good
|
48
|
+
workflow has always been an issue in our discipline. Cloud storage services like
|
49
|
+
[Dropbox](http://www.dropbox.com) are still relatively new among political scientists. Without
|
50
|
+
cloud storage, previous workflow left open the possibility that work between a home computer
|
51
|
+
and an office computer was lost as a function of a corrupted thumb drive, an overheated
|
52
|
+
power supply, or, among other things, the wave of viruses that
|
53
|
+
[would particularly affect Microsoft users every summer](http://money.cnn.com/2003/11/05/technology/microsoftbounty/). Social sciences, [unlike engineering](http://kieranhealy.org/blog/archives/2014/01/23/plain-text/), have traditionally relied on software like Microsoft Word for manuscript
|
54
|
+
preparation though any word processor reduces workflow to a series of clicks and strokes
|
55
|
+
on a keyboard. This is [a terrible way to track changes](http://www.nytimes.com/2013/04/19/opinion/krugman-the-excel-depression.html) or maintain version control. The addition of collaborators
|
56
|
+
only compounds all the aforementioned issues. The proverbial left hand may not know what the
|
57
|
+
right hand is doing.
|
58
|
+
|
59
|
+
I think there is reason for optimism. We only struggle with it now because we have tools
|
60
|
+
like [R Markdown](http://rmarkdown.rstudio.com/) and [Pandoc](http://pandoc.org/), more
|
61
|
+
generally, that make significant strides in workflow. LaTeX resolved earlier issues of corrupted
|
62
|
+
binary files by reducing documents to raw markup that was little more than raw text and
|
63
|
+
revisions that could be easily kept as ["commented" text](http://tex.stackexchange.com/questions/11177/how-to-write-hidden-notes-in-a-latex-file). However, for all its benefits (including pretty PDFs),
|
64
|
+
[LaTeX is *ugly* code](http://www-rohan.sdsu.edu/~aty/bibliog/latex/gripe.html) and does not
|
65
|
+
provide means of seamlessly working with the actual data analysis itself. R Markdown both
|
66
|
+
eliminates markup and allows the author and her collaborators to write and reproduce the
|
67
|
+
manuscript in one fell swoop.
|
68
|
+
|
69
|
+
# Getting Started with YAML
|
70
|
+
|
71
|
+
The lion's share of a R Markdown document will be raw text, though the front matter may be the
|
72
|
+
most important part of the document. R Markdown uses [YAML](http://www.yaml.org/) for its
|
73
|
+
metadata and the fields differ from [what an author would use for a Beamer presentation](http://svmiller.com/blog/2015/02/moving-from-beamer-to-r-markdown/). I provide a sample YAML metadata
|
74
|
+
largely taken from this exact document and explain it below.
|
75
|
+
|
76
|
+
```{r eval=FALSE}
|
77
|
+
---
|
78
|
+
output:
|
79
|
+
pdf_document:
|
80
|
+
citation_package: natbib
|
81
|
+
keep_tex: true
|
82
|
+
fig_caption: true
|
83
|
+
latex_engine: pdflatex
|
84
|
+
template: ~/Dropbox/miscelanea/svm-r-markdown-templates/svm-latex-ms.tex
|
85
|
+
title: "A Pandoc Markdown Article Starter and Template"
|
86
|
+
thanks: "Replication files are available on the author's Github account..."
|
87
|
+
author:
|
88
|
+
- name: Steven V. Miller
|
89
|
+
affiliation: Clemson University
|
90
|
+
- name: Mary Margaret Albright
|
91
|
+
affiliation: Pendelton State University
|
92
|
+
- name: Rembrandt Q. Einstein
|
93
|
+
affiliation: Springfield University
|
94
|
+
abstract: "This document provides an introduction to R Markdown, argues for its..."
|
95
|
+
keywords: "pandoc, r markdown, knitr"
|
96
|
+
date: "`r format(Sys.time(), '%B %d, %Y')`"
|
97
|
+
geometry: margin=1in
|
98
|
+
fontfamily: mathpazo
|
99
|
+
fontsize: 11pt
|
100
|
+
# spacing: double
|
101
|
+
bibliography: ~/Dropbox/master.bib
|
102
|
+
biblio-style: apsr
|
103
|
+
---
|
104
|
+
```
|
105
|
+
|
106
|
+
`output:` will tell R Markdown we want a PDF document rendered with LaTeX. Since we are adding
|
107
|
+
a fair bit of custom options to this call, we specify `pdf_document:` on the next line
|
108
|
+
(with, importantly, a two-space indent). We specify additional output-level options underneath
|
109
|
+
it, each are indented with four spaces. `citation_package: natbib` tells R Markdown to
|
110
|
+
use `natbib` to handle bibliographic citations.[^natbib] Thereafter, the next
|
111
|
+
line (`keep_tex: true`) tells R Markdown to render a raw `.tex` file along with the PDF
|
112
|
+
document. This is useful for both debugging and the publication stage, when the editorial
|
113
|
+
team will ask for the raw `.tex` so that they could render it and later provide page proofs.
|
114
|
+
The next line `fig_caption: true` tells R Markdown to make sure that whatever images are
|
115
|
+
included in the document are treated as figures in which our caption in brackets in a
|
116
|
+
Markdown call is treated as the caption in the figure. The next line
|
117
|
+
(`latex_engine: pdflatex`) tells R Markdown to use pdflatex and not some other option
|
118
|
+
like `lualatex`. For my template, I'm pretty sure this is mandatory.[^pdflatex]
|
119
|
+
|
120
|
+
[^natbib]: R Markdown can use Pandoc's native bibliography management system or even
|
121
|
+
`biblatex`, but I've found that it chokes with some of the more advanced stuff I've done
|
122
|
+
with my .bib file over the years. For example, I've been diligent about special
|
123
|
+
characters (e.g. umlauts and acute accents) in author names in my .bib file, but
|
124
|
+
Pandoc's native citation system will choke on these characters in a .bib file. I
|
125
|
+
effectively need `natbib` for my own projects.
|
126
|
+
|
127
|
+
[^pdflatex]: The main reason I still use `pdflatex` (and most readers probably do as well)
|
128
|
+
is because of LaTeX fonts. [Unlike others](http://www-rohan.sdsu.edu/~aty/bibliog/latex/gripe.html),
|
129
|
+
I find standard LaTeX fonts to be appealing.
|
130
|
+
|
131
|
+
The next line (`template: ...`) tells R Markdown to use my custom LaTeX template.[^path]
|
132
|
+
While I will own any errors in the code, I confess to "Frankensteining" this template
|
133
|
+
from [the default LaTeX template](https://github.com/jgm/pandoc-templates) from Pandoc,
|
134
|
+
[Kieran Healy's LaTeX template](https://github.com/kjhealy/pandoc-templates/tree/master/templates),
|
135
|
+
and liberally using raw TeX from the [Association for Computing Machinery's (ACM) LaTeX template](https://www.acm.org/publications/article-templates/acm-latex-style-guide). I rather like that template
|
136
|
+
since it resembles standard manuscripts when they are published in some of our more prominent
|
137
|
+
journals. I will continue with a description of the YAML metadata in the next paragraph,
|
138
|
+
though invite the curious reader to scroll to the end of the accompanying post to see the
|
139
|
+
PDF this template produces.
|
140
|
+
|
141
|
+
[^path]: Notice that the path is relative. The user can, if she wishes, install this in the
|
142
|
+
default Pandoc directory. I don't think this is necessary. Just be mindful of wherever the
|
143
|
+
template is placed. Importantly, `~` is used in R to find the home directory (not
|
144
|
+
necessarily the working directory). It is equivalent to saying `/home/steve` in Linux,
|
145
|
+
or `/Users/steve` on a Mac, in my case.
|
146
|
+
|
147
|
+
The next fields get to the heart of the document itself. `title:` is, intuitively, the title
|
148
|
+
of the manuscript. Do note that fields like `title:` do not have to be in quotation marks,
|
149
|
+
but must be in quotation marks if the title of the document includes a colon. That said, the
|
150
|
+
only reason to use a colon in an article title is if it is followed by a subtitle, hence the
|
151
|
+
optional field (`subtitle:`). Notice I "comment out" the subtitle in the above example with
|
152
|
+
a pound sign since this particular document does not have a subtitle. If `thanks:` is
|
153
|
+
included and has an accompanying entry, the ensuing title of the document gets an asterisk
|
154
|
+
and a footnote. This field is typically used to advise readers that the document is a
|
155
|
+
working paper or is forthcoming in a journal.
|
156
|
+
|
157
|
+
The next field (`author:`) is a divergence from standard YAML, but I think it is useful. I
|
158
|
+
will also confess to pilfering this idea from Kieran Healy's template. Typically, multiple
|
159
|
+
authors for a given document are separated by an `\and` in this field. However, standard
|
160
|
+
LaTeX then creates a tabular field separating multiple authors that is somewhat restrictive
|
161
|
+
and not easy to override. As a result, I use this setup (again, taken from Kieran Healy) to
|
162
|
+
sidestep the restrictive rendering of authors in the standard `\maketitle` tag. After `author:`,
|
163
|
+
enter `- name:` (no space before the dash) and fill in the field with the first author. On the
|
164
|
+
next line, enter two spaces, followed by `affiliation:` and the institute or university
|
165
|
+
affiliation of the first author.
|
166
|
+
|
167
|
+
Do notice this can be repeated for however many co-authors there are to a manuscript. The
|
168
|
+
rendered PDF will enter each co-author in a new line in a manner similar to journals like
|
169
|
+
*American Journal of Political Science*, *American Political Science Review*, or *Journal
|
170
|
+
of Politics*.
|
171
|
+
|
172
|
+
The next two fields pertain to the frontmatter of a manuscript. They should also be intuitive
|
173
|
+
for the reader. `abstract` should contain the abstract and `keywords` should contain some
|
174
|
+
keywords that describe the research project. Both fields are optional, though are practically
|
175
|
+
mandatory. Every manuscript requires an abstract and some journals---especially those published
|
176
|
+
by Sage---request them with submitted manuscripts. My template also includes these keywords in
|
177
|
+
the PDF's metadata.
|
178
|
+
|
179
|
+
`date` comes standard with R Markdown and you can use it to enter the date of the most recent
|
180
|
+
compile. I typically include the date of the last compile for a working paper in the `thanks:`
|
181
|
+
field, so this field currently does not do anything in my Markdown-LaTeX manuscript template. I
|
182
|
+
include it in my YAML as a legacy, basically.
|
183
|
+
|
184
|
+
The next items are optional and cosmetic. `geometry:` is a standard option in LaTeX. I set
|
185
|
+
the margins at one inch, and you probably should too. `fontfamily:` is optional, but I use
|
186
|
+
it to specify the Palatino font. The default option is Computer Modern Roman. `fontsize:`
|
187
|
+
sets, intuitively, the font size. The default is 10-point, but I prefer 11-point. `spacing:`
|
188
|
+
is an optional field. If it is set as "double", the ensuing document is double-spaced. "single"
|
189
|
+
is the only other valid entry for this field, though not including the entry in the YAML
|
190
|
+
metadata amounts to singlespacing the document by default. Notice I have this "commented out"
|
191
|
+
in the example code.
|
192
|
+
|
193
|
+
The final two options pertain to the bibliography. `bibliography:` specifies the location
|
194
|
+
of the .bib file, so the author could make citations in the manuscript. `biblio-style`
|
195
|
+
specifies the type of bibliography to use. You'll typically set this as APSR. You could
|
196
|
+
also specify the relative path of [my *Journal of Peace Research* .bst file](http://svmiller.com/miscellany/journal-of-peace-research-bst-file/) if you are submitting to that journal.
|
197
|
+
|
198
|
+
# Getting Started with Markdown Syntax
|
199
|
+
|
200
|
+
There are a lot of cheatsheets and reference guides for Markdown (e.g.
|
201
|
+
[Adam Prichard](https://github.com/adam-p/markdown-here/wiki/Markdown-Cheatsheet),
|
202
|
+
[Assemble](http://assemble.io/docs/Cheatsheet-Markdown.html),
|
203
|
+
[Rstudio](https://www.rstudio.com/wp-content/uploads/2015/02/rmarkdown-cheatsheet.pdf),
|
204
|
+
[Rstudio again](https://www.rstudio.com/wp-content/uploads/2015/03/rmarkdown-reference.pdf),
|
205
|
+
[Scott Boms](http://scottboms.com/downloads/documentation/markdown_cheatsheet.pdf),
|
206
|
+
[Daring Fireball](https://daringfireball.net/projects/markdown/syntax), among, I'm sure,
|
207
|
+
several others). I encourage the reader to look at those, though I will retread these
|
208
|
+
references here with a minimal working example below.
|
209
|
+
|
210
|
+
```markdown
|
211
|
+
|
212
|
+
# Introduction
|
213
|
+
|
214
|
+
**Lorem ipsum** dolor *sit amet*.
|
215
|
+
|
216
|
+
- Single asterisks italicize text *like this*.
|
217
|
+
- Double asterisks embolden text **like this**.
|
218
|
+
|
219
|
+
Start a new paragraph with a blank line separating paragraphs.
|
220
|
+
|
221
|
+
- This will start an unordered list environment, and this will be the first item.
|
222
|
+
- This will be a second item.
|
223
|
+
- A third item.
|
224
|
+
- Four spaces and a dash create a sublist and this item in it.
|
225
|
+
- The fourth item.
|
226
|
+
|
227
|
+
1. This starts a numerical list.
|
228
|
+
2. This is no. 2 in the numerical list.
|
229
|
+
|
230
|
+
# This Starts A New Section
|
231
|
+
## This is a Subsection
|
232
|
+
### This is a Subsubsection
|
233
|
+
#### This starts a Paragraph Block.
|
234
|
+
|
235
|
+
> This will create a block quote, if you want one.
|
236
|
+
|
237
|
+
Want a table? This will create one.
|
238
|
+
|
239
|
+
Table Header | Second Header
|
240
|
+
------------- | -------------
|
241
|
+
Table Cell | Cell 2
|
242
|
+
Cell 3 | Cell 4
|
243
|
+
|
244
|
+
Note that the separators *do not* have to be aligned.
|
245
|
+
|
246
|
+
Want an image? This will do it.
|
247
|
+
|
248
|
+
![caption for my image](path/to/image.jpg)
|
249
|
+
|
250
|
+
`fig_caption: yes` will provide a caption. Put that in the YAML metadata.
|
251
|
+
|
252
|
+
Almost forgot about creating a footnote.[^1] This will do it again.[^2]
|
253
|
+
|
254
|
+
[^1]: The first footnote
|
255
|
+
[^2]: The second footnote
|
256
|
+
|
257
|
+
Want to cite something?
|
258
|
+
|
259
|
+
- Find your biblatexkey in your bib file.
|
260
|
+
- Put an @ before it, like @smith1984, or whatever it is.
|
261
|
+
- @smith1984 creates an in-text citation (e.g. Smith (1984) says...)
|
262
|
+
- [@smith1984] creates a parenthetical citation (Smith, 1984)
|
263
|
+
|
264
|
+
That'll also automatically create a reference list at the end of the document.
|
265
|
+
|
266
|
+
[In-text link to Google](http://google.com) as well.
|
267
|
+
```
|
268
|
+
|
269
|
+
That's honestly it. Markdown takes the chore of markup from your manuscript (hence: "Markdown").
|
270
|
+
|
271
|
+
On that note, you could easily pass most LaTeX code through Markdown if you're writing a
|
272
|
+
LaTeX document. However, you don't need to do this (unless you're using the math environment)
|
273
|
+
and probably shouldn't anyway if you intend to share your document in HTML as well.
|
274
|
+
|
275
|
+
# Using R Markdown with Knitr
|
276
|
+
|
277
|
+
Perhaps the greatest intrigue of R Markdown comes with the [`knitr` package](http://yihui.name/knitr/)
|
278
|
+
provided by @xie2013ddrk. In other words, the author can, if she chooses, do the analysis
|
279
|
+
in the Markdown document itself and compile/execute it in R.
|
280
|
+
|
281
|
+
Take, for example, this simple exercise using the `voteincome` data from the `Zelig` package.
|
282
|
+
Suppose I want to explain the decision to vote using data from this package. I load in the
|
283
|
+
data, clean the data, run the analyses, and present the results as a coefficient plot.
|
284
|
+
|
285
|
+
Here's what this code looks like. All I did was create a code display, which starts with
|
286
|
+
three *backticks* (i.e. those ticks next to the number 1 key on your keyboard) and ends with
|
287
|
+
three backticks on another line. On the first line of backticks (i.e. to start the code
|
288
|
+
display) enter `{r, eval=FALSE, tidy=TRUE}`. The `eval=FALSE` option just displays the
|
289
|
+
R code (and does not run it), `tidy=TRUE` wraps long code so it does not run off the page.
|
290
|
+
|
291
|
+
Within that code display, I enter my R code like this.
|
292
|
+
|
293
|
+
```{ruby install_packages, echo = FALSE}
|
294
|
+
R.install_and_loads 'Zelig'
|
295
|
+
R.install_and_loads 'formatR'
|
296
|
+
R.install_and_loads 'arm'
|
297
|
+
R.install_and_loads 'stargazer'
|
298
|
+
```
|
299
|
+
|
300
|
+
```{r zelig, eval=FALSE, tidy = TRUE}
|
301
|
+
suppressMessages(library(Zelig))
|
302
|
+
suppressMessages(library(arm))
|
303
|
+
suppressMessages(library(coefplot))
|
304
|
+
|
305
|
+
data(voteincome)
|
306
|
+
|
307
|
+
voteincome$z.age <- arm::rescale(voteincome$age)
|
308
|
+
voteincome$z.education <- arm::rescale(voteincome$education)
|
309
|
+
voteincome$z.income <- arm::rescale(voteincome$income)
|
310
|
+
|
311
|
+
M1 <- glm(vote ~ z.age + female + z.education + z.income,
|
312
|
+
data=voteincome, family=binomial)
|
313
|
+
|
314
|
+
coefplot(M1)
|
315
|
+
```
|
316
|
+
|
317
|
+
The implications for workflow are faily substantial. Authors can rather quickly display the code
|
318
|
+
they used to run the analyses in the document itself (likely in the appendix). As such, there's
|
319
|
+
little guesswork for reviewers and editors in understanding what the author did in the
|
320
|
+
analyses reported in the manuscript.
|
321
|
+
|
322
|
+
It doesn't end there. In fact, here's what happens when `eval=FALSE` is omitted or changed
|
323
|
+
to `eval=TRUE`. Now, the code runs within R. Observe.
|
324
|
+
|
325
|
+
```{r voteincome, eval=TRUE, tidy = TRUE, cache=FALSE, fig.cap="A Coefficient Plot"}
|
326
|
+
suppressMessages(library(Zelig))
|
327
|
+
suppressMessages(library(arm))
|
328
|
+
|
329
|
+
|
330
|
+
data(voteincome)
|
331
|
+
|
332
|
+
voteincome$z.age <- arm::rescale(voteincome$age)
|
333
|
+
voteincome$z.education <- arm::rescale(voteincome$education)
|
334
|
+
voteincome$z.income <- arm::rescale(voteincome$income)
|
335
|
+
|
336
|
+
M1 <- glm(vote ~ z.age + female + z.education + z.income,
|
337
|
+
data=voteincome, family=binomial)
|
338
|
+
|
339
|
+
# arm::coefplot(M1)
|
340
|
+
```
|
341
|
+
|
342
|
+
To get `knitr` to present the results of a table, add `results="asis"` to the brackets to
|
343
|
+
start the R code chunk. The ensuing output will look like this (though the table may come on
|
344
|
+
the next page).
|
345
|
+
|
346
|
+
```{r startgazer, eval=TRUE, tidy = TRUE, size="small", cache=FALSE, results="asis"}
|
347
|
+
suppressMessages(library(Zelig))
|
348
|
+
suppressMessages(library(stargazer))
|
349
|
+
suppressMessages(library(arm))
|
350
|
+
|
351
|
+
data(voteincome)
|
352
|
+
|
353
|
+
voteincome$z.age <- arm::rescale(voteincome$age)
|
354
|
+
voteincome$z.education <- arm::rescale(voteincome$education)
|
355
|
+
voteincome$z.income <- arm::rescale(voteincome$income)
|
356
|
+
|
357
|
+
|
358
|
+
M1 <- glm(vote ~ z.age + female + z.education + z.income,
|
359
|
+
data=voteincome, family=binomial)
|
360
|
+
|
361
|
+
stargazer(M1, title="A Handsome Table", header=FALSE)
|
362
|
+
```
|
363
|
+
|
364
|
+
Adding `echo="FALSE"` inside the brackets to start the R chunk will omit the presentation of
|
365
|
+
the R commands. It will just present the table. This provides substantial opportunity for
|
366
|
+
authors in doing their analyses. Now, the analysis and presentation in the form of a
|
367
|
+
polished manuscript can be effectively simultaneous.[^4]
|
368
|
+
|
369
|
+
[^4]: I'm not sure if I'm ready to commit to this myself since my workflow is still largely
|
370
|
+
derived from [Rob J. Hyndman's example](http://robjhyndman.com/hyndsight/workflow-in-r/).
|
371
|
+
However, *knitr* has endless potential, especially when analyses can stored in cache, saved
|
372
|
+
as chunks, or loaded in the preamble of a document to reference later in the manuscript.
|
373
|
+
|
374
|
+
|
375
|
+
<!--
|
376
|
+
# References
|
377
|
+
\setlength{\parindent}{-0.2in}
|
378
|
+
\setlength{\leftskip}{0.2in}
|
379
|
+
\setlength{\parskip}{8pt}
|
380
|
+
\vspace*{-0.2in}
|
381
|
+
\noindent
|
382
|
+
-->
|