Introduction to R Markdown
本页目录· 11 条
这一页有部分内容暂时无法显示,其余内容完整。
learning.monash.edulearning.monash.edu/pluginfile.php/5794849/mod_resource/content/4/FIT5145_S2_2020_Week1_intro_to_RMarkdown.htmlWhat is R Markdown
- R Markdown (.Rmd) is an authoring format that enables easy creation of documents, presentations, and reports from R. It uses the R packages
rmarkdownandknitrto make it all work. All coding exercises that you complete for this course and throughout the microcredential need to be in R Markdown.R Markdown (.Rmd) 是一种创作格式,支持使用 R 轻松创建文档、演示文稿和报告。它使用 R 包
rmarkdown和knitr来实现所有功能。您在本课程以及整个微认证过程中完成的所有编程练习都必须使用 R Markdown 编写。 - It combines the core syntax of markdown (an easy-to-write plain text format) with embedded R code chunks that are run so their output can be included in the final document.
它将 markdown 的核心语法(一种易于编写的纯文本格式) 与嵌入的 R 代码块相结合,以便运行它们的输出可以包含在最终文档中。
- R Markdown documents are fully reproducible (they can be automatically regenerated whenever underlying R code or data changes).
R Markdown 文档是完全可复制的(每当底层 R 代码或数据发生变化时,它们都可以自动重新生成)。
- An R Markdown file is a plain text file that has the extension
.RmdR Markdown 文件是纯文本文件,扩展名为
.Rmd
Create your own R Markdown
Code chunks
Headings
Lists
-, *, + for creating a bullet or unordered list
1., 2. for creating a ordered list
Links
Images
Attribution
Remember, when you use someone else’s work, you need to check its copyright, permissions or licensing to determine if you can use it, and then appropriately attribute. For example, the image of the unused postcard is in the Public Domain and made available by the National Museum of Australia. The image could be attributed in the following format:
请记住,使用他人作品时,需要检查其版权、许可或授权,以确定是否可以使用,然后进行适当的署名。例如,未使用的明信片图像属于公共领域 ,由澳大利亚国家博物馆提供。该图像可以采用以下格式进行署名:
Compiling, or ‘making the output’
select Knit for compiling
select Run for running the coding pieces
Reporting styles
With R Markdown, you can create different kinds of reports by changing the output YAML (Yet another markup language) tag or by selecting the ‘Knit’ drop down in RStudio.
使用 R Markdown,您可以通过更改输出 YAML(另一种标记语言)标签或选择 RStudio 中的 “Knit” 下拉菜单来创建不同类型的报告。
There are many extension reporting types available using external packages. For example, you can create interactive tutorials with the learnr package or interactive dashboards with the flexdashboard package. You can even write whole books (using the bookdown package ) or use it to create a personal website (using the blogdown package), or even use other computer languages in the same document. These all follow the same principles as regular R Markdown, so once you understand the basics, you can easily try out other styles!
使用外部包可以扩展多种报告类型。例如,您可以使用learnr包创建交互式教程,或使用flexdashboard包创建交互式仪表板。您甚至可以编写整本书(使用bookdown包),或使用它创建个人网站(使用blogdown包),甚至可以在同一文档中使用其他计算机语言 。这些都遵循与常规 R Markdown 相同的原则,因此一旦您掌握了基础知识,就可以轻松尝试其他样式!
Give it a go!
In RStudio Console
install.packages("tidyverse")
or install by click Install
Knit
此处有一段内容暂不支持显示。
此处有一段内容暂不支持显示。
summary(avengers)
数值型字段解释
| 项目 | 含义 |
|---|---|
| Min. | 最小值:2 ➜ 有角色只出现过 2 次 |
| 1st Qu. | 第一四分位数:58 ➜ 25% 的角色出现次数低于 58 |
| Median | 中位数:132 ➜ 一半的角色出现次数低于 132 |
| Mean | 平均值:414.1 ➜ 所有角色的平均出现次数 |
| 3rd Qu. | 第三四分位数:491 ➜ 75% 的角色出现次数低于 491 |
| Max. | 最大值:4333 ➜ 有个角色出现了 4333 次 |
字符型字段解释
- Class:说明这一列是字符型
character 字符串类型 numeric 数值型 factor 因子型 logical 布尔型,TURE/FALSE data.frame 数据框 - Length:共有 173 行数据
- Mode:也是字符数据类型
在 R 中,“Mode” 是一种底层数据结构描述方式,跟 class 很像,但更底层一点(基础存储结构