1.1 coding standards
.常用文本文件/文本编辑器,即 text files/text editor
.缩进代码
。缩进提高可读性
。修正行长(80列)能让你从容的面对嵌套和长函数
。小建议:最少缩进(4个格);8个最理想
.限制代码的宽度(80列?可否随自己)
.限制单个函数的长度,避免又臭又长的函数
1.2 markdown相关文件
What is Markdown?
"Markdown is a text-to-HTML conversion tool for web writers. Markdown allows you to write using an easy-to-read, easy-to-write plain text format(纯文本), then convert it to structurally valid XHTML (or HTML)."
- John Gruber, creator of Markdown
Markdown Resources
What is Markdown?
-
Created by John Gruber and Aaron Swartz
-
A simplified version of "markup" languages
-
Allows one to focus on writing as opposed to formatting
-
Simple/minimal intuitive formatting elements
-
Easily converted to valid HTML (and other formats) using existing tools
-
Complete information is available at http://daringfireball.net/projects/markdown/
-
Some background information at http://daringfireball.net/2004/03/dive_into_markdown
What is R Markdown?
-
R markdown is the integration of R code with markdown
-
Allows one to create documents containing "live" R code
-
R code is evaluated as part of the processing of the markdown
-
Results from R code are inserted into markdown document
-
A core tool in literate statistical programming
-
What is R Markdown?
-
R markdown can be converted to standard markdown using the knitr package in R
-
Markdown can be converted to HTML using the markdown package in R
-
Any basic text editor can be used to create a markdown document; no special editing tools needed
-
The R markdown --> markdown --> HTML work flow can be easily managed using R Studio (but not required)
-
These slides were written in R markdown and converted to slides using the slidify package
当然有时也可如下
library(knitr)
setwd(<working directory>)
knit2html("document. Rmd")将输出变为html格式
browseURL("document.html")将上面输出的那个打开
knitr文件的过程(在黑匣子下发生了什么?)
书写RMarkdown文件(.Rmd)
knitr产生了一个Markdown文件(.md)
knitr将Markdown文件转化为HTML(默认)
.rmd-.md-.html
如果没有完成的话,最好不好去碰(比如说edit/save)这些.md或是.html文件
some common Options
.output
-results: "asis","hide"
-echo:TRUE,FALSE
figures
-fig.height:numeric
-fig.width:numeric
asis 意味着不postprocess这结果,而是用原始结果来输出