rmarkdown开始使用rmarkdown


备注

本节概述了rmarkdown是什么,以及开发人员为什么要使用它。

它还应该提到rmarkdown中的任何大型主题,并链接到相关主题。由于rmarkdown的文档是新的,您可能需要创建这些相关主题的初始版本。

你好,世界!

---
title: "Hello World!"
output: html_document
---

```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = FALSE)

# Running the setup first allows you to set the options for how each chunk of R code
# will be handled, and the options are in fact part of the first chunk.
# In this example, I've set the echo = FALSE so the R code isn't displayed to the user

#Note that if you want to load any other dependencies, you can load them here:
library(ggplot2)

# Always end the chunk before moving on to the regular markdown content using:

```

# Getting Started with RMarkdown

The heading is denoted with the hashtag (#) and a space. Review the pandoc markdown 
to see what's available knowing you can always write customized 
HTML or LaTeX as needed.

```{r intro, echo=TRUE}
# for this chunk, I turned the echo = TRUE so you can see the R output.
# each chunk should have different names so you can easily debug your code

```

# Graphs with RMarkdown

```{r graphs}
data <- cars
ggplot(data, aes(x = speed, y = dist)) +
  geom_point()
```

# Tables with RMarkdown

## Using R Output

```{r tables, echo =FALSE}
# table with just R output
head(cars, n=10)
```

## Tables with RMarkdown

## Using grid.draw

```{r tables_grid}
# table with grid/gridExtra packages
library(grid)
library(gridExtra)
x <- tableGrob(head(cars, n=10))
grid.draw(x)

```

# You got this!

Now try changing the output in the header/YAML from html_document to ioslides_presentation and see how things change!
 

安装或设置

有关设置或安装rmarkdown的详细说明。