forked from joanby/r-basic
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path01-EjemploRMD.Rmd
64 lines (46 loc) · 1.59 KB
/
01-EjemploRMD.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
---
title: "Ejemplo de R Markdown"
author: "Curso de Estadística Descriptiva"
date: "21/12/2018"
output:
html_document:
df_print: paged
---
```{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=TRUE}
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.
### Nuestras propias chunks
Vamos a calcular $\sqrt{2} - e^{-2}$:
```{r miPrimeraChunk, echo = TRUE, eval = TRUE, results='markup'}
sqrt(2) - exp(-2)
x = 1:5
sqrt(x)
```
```{r magic, message=TRUE, results='markup'}
library(magic)
magic(6)
```
Cuando queremos hacer la raíz cuadrada de dos, podemos hacerlo:
- En $\LaTeX$: $\sqrt{2}$
- En `R` haciendo `r sqrt(2)`
- La frase completa: $\sqrt{2}=$ `r sqrt(2)`
El número $\pi$ empieza por `r pi`.
```{r prueba, results='hide', echo=FALSE}
notas = c(3,5,7,7,9,10,4,7,9)
media = mean(notas)
n = length(notas)
desv.tip = sd(notas)
```
Este año he hecho $n=$ `r n` examenes, con una media $\overline{x}=$ `r round(media,2)` y una desviación típica de $s=$ `r round(desv.tip,2)`.