Upload
others
View
0
Download
0
Embed Size (px)
Citation preview
CIENCIA UANL / AÑO 17, No. 67, MAYO-JUNIO 2014 85
CiENCiAUANL TIPS BIOESTADÍSTICOS
Tema 36:R Commander R Markdown II
PETER B. MANDEVILLE*
Far out in the uncharted backwaters of the unfashionableend 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 planetwhose ape-descended life forms are so amazingly primitivethat they still think digital watches are a pretty neat idea.
D. Adams1
*Consultor Asociado, BioEstadística, S.C.(www.bioestadistica.com)Contacto: [email protected]
En el tema 352 se presentó cómo escribir code chunksen R Commander -> R Markdown. Entre los codechunks se puede incluir texto que es básicamente HyperText Markup Language (HTML). Para incluir carac-teres que no son American Standard Code for Informa-tion Interchange (ASCII), se utilizan los códigos deASCII extendido, en la tabla siguiente se muestranalgunos de los más importantes:
Nótese que solamente los caracteres ASCII queutiliza Notepad funcionan en los comandos de R3, yque los caracteres ASCII extendidos que utiliza Wordno funcionan.
R Commander4 versión 2.0-4 introduce loscomandos siguientes en los menús:
File -> Open R Markdown file…
Edit -> Edit R Markdown document
Se copia y pega el código R Markdown CheatSheet, que sigue en el archivo This PC -> Documents-> CheatSheet.txt.
Entonces se introduce el archivo de código enRcmdr con File -> Open R Markdown file o con Edit-> Edit R Markdown document.
Se puede almacenar el archivo de código como unarchivo R Markdown (.Rmd), con File -> Save RMarkdown file… o con File -> Save R Markdown fileas...
Entonces, se puede generar el documento HTMLcon R Markdown -> Generate HTML report. Tam-bién se puede generar el documento HTML en R con:
library(knitr)knit2html(«CheatSheet.Rmd»)
o con:
CIENCIA UANL / AÑO 17, No. 67, MAYO-JUNIO 201486
library(knitr)knit2html(«CheatSheet.txt»)
Si se hacen cambios en el archivo en Rcmdr, singuardar los cambios con File -> Save R Markdownfile… o con File -> Save R Markdown file as…, éstosse perderán al salir de Rcmdr.
Después se pueden comparar los resultados de lageneración HTML con los comandos de formateo enel 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 unalínea (renglón) vacía
This planet has - or rather had - aproblem, which was this: most of the people livingon it were unhappy for pretty much of the time.Many solutions were suggested for this problem,but most of these were largely concerned with themovements of small green pieces of paper, which isodd because on the whole it wasn’t the small greenpieces of paper that were unhappy. [1]
And so the problem remained; lots of the peoplewere mean, and most of them were miserable, eventhe ones with digital watches. [1]
#### Se puede escribir un párrafo en unalínea larga
Many were increasingly of the opinion thatthey’d all made a big mistake in coming down fromthe trees in the first place. And some said that eventhe trees had been a bad move, and that no oneshould 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 treefor 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-unicode-symbols/)
CIENCIA UANL / AÑO 17, No. 67, MAYO-JUNIO 2014 87
### Listas
#### Lista con viñetas de círculoscerrados
* Bullet 1* Bullet 2* Bullet 2a* Bullet 2b* Bullet 3
#### Lista anidada con viñetas decírculos cerrados y vi/#241;etas abiertos
* Bullet 1* Bullet 2 * Bullet 2a * Bullet 2b* Bullet 3
#### Lista enumerada
1. Media2. Mediana3. 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. Lon-
don: 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.R-
project.org/
4. Fox J. The R Commander: A Basic Statistics Graphical
User Interface to R. Journal of Statistical Software.
2005;14(9):1-42.