Tema 36: R Commander R Markdown II

rcommander2

PETER B. MANDEVILLE*

CIENCIA UANL / AÑO 17, No. 67, MAYO-JUNIO 2014

Artículo en PDF

Far out in the uncharted backwaters of the unfashionable end of the western spiral arm of the Galaxy lies a small unregarded yellow sun. Orbiting this at a distance of roughly ninety-two million miles is an utterly insignificant little blue green planet whose ape-descended life forms are so amazingly primitive that they still think digital watches are a pretty neat idea.

D. Adams (1)

En el tema 35 (2) se presentó cómo escribir code chunks en R Commander -> R Markdown. Entre los code chunks se puede incluir texto que es básicamente Hyper Text Markup Language (HTML). Para incluir caracteres que no son American Standard Code for Information Interchange (ASCII), se utilizan los códigos de ASCII extendido, en la tabla siguiente se muestran algunos de los más importantes:

rcommandermarkdown1

Nótese que solamente los caracteres ASCII que utiliza Notepad funcionan en los comandos de R3, y que los caracteres ASCII extendidos que utiliza Word no funcionan.

R Commander4 versión 2.0-4 introduce los comandos siguientes en los menús:

File -> Open R Markdown file…

Edit -> Edit R Markdown document

Se copia y pega el código R Markdown Cheat Sheet, que sigue en el archivo This PC -> Documents -> CheatSheet.txt.

Entonces se introduce el archivo de código en Rcmdr con File -> Open R Markdown file o con Edit-> Edit R Markdown document.

Se puede almacenar el archivo de código como un archivo R Markdown (.Rmd), con File -> Save R Markdown file… o con File -> Save R Markdown file as…

Entonces, se puede generar el documento HTML con R Markdown -> Generate HTML report. También se puede generar el documento HTML en R con:

library(knitr)
knit2html(«CheatSheet.Rmd»)

o con:

library(knitr)
knit2html(«CheatSheet.txt»)

Si se hacen cambios en el archivo en Rcmdr, sin guardar los cambios con File -> Save R Markdown file… o con File -> Save R Markdown file as…, éstos se perderán al salir de Rcmdr.

Después se pueden comparar los resultados de la generación HTML con los comandos de formateo en el artículo.

R Markdown Cheat Sheet
=======================
### pbm
### ‘r as.character(Sys.Date())‘
“‘{r echo=FALSE}
opts_chunk$set(comment=NA, prompt=TRUE,
out.width=750, fig.height=8, fig.width=8)
library(Rcmdr)
“‘
“‘{r}
setwd(«E:/CIENCIA UANL/Tips 36»)
“‘
“‘{r}
sessionInfo()
“‘
### Secciones

#### Titulo

# Titulo

Titulo
=====

### Sección

Sección
———

### Subsección

#### SubSubsección

###### SubSubSubSubsección

### Pârrafos

#### Se separa párrafos con una
línea (renglón) vacía

This planet has - or rather had - a problem, which was this: most of the people living on it were unhappy for pretty much of the time. Many solutions were suggested for this problem, but most of these were largely concerned with the movements of small green pieces of paper, which is odd because on the whole it wasn’t the small green pieces of paper that were unhappy. [1]

And so the problem remained; lots of the people were mean, and most of them were miserable, even the ones with digital watches. [1]

#### Se puede escribir un párrafo en una línea larga

Many were increasingly of the opinion that they’d all made a big mistake in coming down from the trees in the first place. And some said that even the trees had been a bad move, and that no one should ever have left the oceans. [1]

#### o en líneas separadas

And then, one Thursday, nearly two thousand years after one man had been nailed to a tree for saying how great it would be to be nice to people for a change,…[1]

### Énfasis

*Cursiva* y **negrito** son fáciles,

_Cursiva_ y __negrito__ son fáciles.

### Ligas

Se pueden crear ligas

[códigos html ascii extendido]( http://techmantium.com/html-entity-codes-ascii-unicodesymbols/)

### Listas

#### Lista con viñetas de círculos cerrados

* Bullet 1
* Bullet 2
* Bullet 2a
* Bullet 2b
* Bullet 3

#### Lista anidada con viñetas de círculos cerrados y vi/#241;etas abiertos

* Bullet 1
* Bullet 2
* Bullet 2a
* Bullet 2b
* Bullet 3

#### Lista enumerada

1. Media
2. Mediana
3. Moda

### Tablas

“‘{r results=»asis»}
kable(head(iris[,1:3]),align=c(«l»,»r»,»c»))
“‘
Para hacer el comando invisible, modifica el
*chunk* así:

“‘{r results=»asis», echo=FALSE}
kable(head(iris[,1:3]),align=c(«l»,»r»,»c»))
“‘

Referencias

1. Adams D. The Hitchhiker’s Guide to the Galaxy. London: Pan Books; 1979.

2. Mandeville PB, Tema 35: Investigación reproducible con R Commander. CiENCiAUANL. Ene.-Feb. 2014;17(65):77-80.

3. R Core Team. R: A language and environment for statistical computing. R Foundation for Statistical Computing, Vienna; 2014. URL http://www.Rproject. org/

4. Fox J. The R Commander: A Basic Statistics Graphical User Interface to R. Journal of Statistical Software. 2005;14(9):1-42.