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

## 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

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:

## 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.

## 1.3. Latex

Texstudio, or Rstudio+KnitR+Sweave

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

## 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.