Loading...
 

Data management, markdown, latex, notebooks (X. de Pedro) May 31

1.1. Introduction

1.1.1. Data Management

Tidyverse:

  • Cheatsheets:
  • Installation:
    install.packages("tidyverse")
  • Book:

    R for Data Science. Garrett Grolemund, Hadley Wickham. O’Reilly January 2017 First Edition
    http://r4ds.had.co.nz

    Welcome

    This is the website for “R for Data Science”. This book will teach you how to do data science with R: You’ll learn how to get your data into R, get it into the most useful structure, transform it, visualise it and model it. In this book, you will find a practicum of skills for data science. Just as a chemist learns how to clean test tubes and stock a lab, you’ll learn how to clean data and draw plots—and many other things besides. These are the skills that allow data science to happen, and here you will find the best practices for doing each of these things with R. You’ll learn how to use the grammar of graphics, literate programming, and reproducible research to save time. You’ll also learn how to manage cognitive resources to facilitate discoveries when wrangling, visualising, and exploring data.

  • Exercises


See:

Image

1.1.2. Markdown

RStudio

---
title: "Untitled"
author: "Ajuntament de Barcelona - AAI"
date: "28 febrer de 2018"
output: html_document
---

```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```

## R Markdown

This is an R Markdown document. Markdown is a simple formatting syntax for authoring HTML, PDF, and MS Word documents. 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:

```{r cars}
summary(cars)
```

## Including Plots

You can also embed plots, for example:

```{r pressure, echo=FALSE}
plot(pressure)
```

Note that the `echo = FALSE` parameter was added to the code chunk to prevent printing of the R code that generated the plot.



See all lessons from RStudio:

  1. Introduction - https://rmarkdown.rstudio.com/lesson-1.html
  2. How It Works - https://rmarkdown.rstudio.com/lesson-2.html
  3. Code Chunks - https://rmarkdown.rstudio.com/lesson-3.html
  4. Inline Code - https://rmarkdown.rstudio.com/lesson-4.html
  5. Code Languages - https://rmarkdown.rstudio.com/lesson-5.html
  6. Parameters - https://rmarkdown.rstudio.com/lesson-6.html
  7. Tables - https://rmarkdown.rstudio.com/lesson-7.html
  8. Markdown Basics - https://rmarkdown.rstudio.com/lesson-8.html
  9. Output Formats - https://rmarkdown.rstudio.com/lesson-9.html
  10. Notebooks - https://rmarkdown.rstudio.com/lesson-10.html
  11. Slide Presentations - https://rmarkdown.rstudio.com/lesson-11.html
  12. Dashboards - https://rmarkdown.rstudio.com/lesson-12.html
  13. Websites - https://rmarkdown.rstudio.com/lesson-13.html
  14. Interactive Documents - https://rmarkdown.rstudio.com/lesson-14.html
  15. Cheatsheets - https://rmarkdown.rstudio.com/lesson-15.html

1.1.3. Latex

Texstudio, or Rstudio+KnitR+Sweave/pandoc

See:


Example:

% trial .tex file %
\documentclass[10pt]{article}  % specifies document class (article) and point size (10pt)

\begin{document}               % starts document

\title{Example Document}       % specifies big, fancy title
\maketitle                     % constructs big, fancy title
\section{Section 1}            % makes a section header
Here is some text in section 1.  Section 1 also contains an itemized list:
  \begin{itemize}              % initiates an itemized list
    \item Here is an item in the list
    \item Here is a second item
  \end{itemize}                % ends itemized list

\section{Section 2}            % makes header for section 2   
Some text on section 2 here.  Section 2 contains an enumerated list.
  \begin{enumerate}            % initiates enumerated list
    \item A first enumerated item
    \item A second enumerated item
  \end{enumerate}              % ends enumerated list

\end{document}                 % ends document


Latex Collaborative Editors online

Overleaf

Overleaf ( https://www.overleaf.com ) is yet another online LaTeX editor. Similar to ShareLaTeX, it offers separate pricing plans for professionals and students. It also includes a free plan where you can sync with GitHub, check your revision history, and add multiple collaborators.

There’s a limit on the number of files you can create per project – so it could bother if you are a professional working with LaTeX documents most of the time.

ShareLatex

ShareLaTeX ( https://www.sharelatex.com ) is an online LaTeX editor. If you want someone (or a group of people) to collaborate on documents you are working on, this is what you need.

It offers a free plan along with several paid packages. Even the students of Harvard University & Oxford University utilize this for their projects. With the free plan, you get the ability to add one collaborator.

The paid packages let you sync the documents on GitHub and Dropbox along with the ability to record the full document history. You can choose to have multiple collaborators as per your plan. For students, there’s a separate pricing plan available.

1.1.4. Notebooks

---
title: "R Notebook"
output: html_notebook
---

This is an [R Markdown](http://rmarkdown.rstudio.com) Notebook. When you execute code within the notebook, the results appear beneath the code. 

Try executing this chunk by clicking the *Run* button within the chunk or by placing your cursor inside it and pressing *Ctrl+Shift+Enter*. 

```{r}
plot(cars)
```

Add a new chunk by clicking the *Insert Chunk* button on the toolbar or by pressing *Ctrl+Alt+I*.

When you save the notebook, an HTML file containing the code and output will be saved alongside it (click the *Preview* button or press *Ctrl+Shift+K* to preview the HTML file).

The preview shows you a rendered HTML copy of the contents of the editor. Consequently, unlike *Knit*, *Preview* does not run any R code chunks. Instead, the output of the chunk when it was last run in the editor is displayed.

1.2. Hands-on work

1.2.1. Hello-World Demo

Follow this tutorial as a starting point:
https://medium.com/@sorenlind/create-pdf-reports-using-r-r-markdown-latex-and-knitr-on-windows-10-952b0c48bfa9

1.2.2. A step-by-step markdown example

A step by step guide to learn the basics of RMarkdown
https://gist.github.com/jeromyanglim/2716336

1.2.3. Learn LaTeX in 30 minutes

From sharelatex.com:
https://es.sharelatex.com/learn/Learn_LaTeX_in_30_minutes

You can practice online here: https://latexbase.com


foo



Alias names for this page:
markdown

Image Seed: noun \ˈsēd\ : the beginning of something which continues to develop or grow

Knowledge seeds

Switch Language