如何编写r块以加载tidyverse? [关闭]

问题描述 投票:-2回答:2

[在下面创建一个R块,在其中加载tidyverse库。[这是一个分配问题。我对自己应该做的事情有疑问吗?]我是否只编写命令来加载库?还是需要编写一个单独的r块?

r
2个回答
0
投票

由于看起来您正在使用R Markdown,所以它与另一个答案类似,但是如果您在谈论块,则应该是:

```{r setup, include=FALSE}

library(tidyverse)

```

通常在生成R Markdown文档时要在R Setup块中调用包。

这里是带有R Markdown“新”文档模板的完整示例。

---
title: "Untitled"
output: html_document
---

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

library(tidyverse)
```

## R Markdown

This is an R Markdown document. Markdown is a simple formatting syntax for authoring HTML, PDF, and MS Word documents. For more details on using R Markdown see <http://rmarkdown.rstudio.com>.

When you click the **Knit** button a document will be generated that includes both content as well as the output of any embedded R code chunks within the document. You can embed an R code chunk like this:

```{r cars}
summary(cars)
```

## Including Plots

You can also embed plots, for example:

```{r pressure, echo=FALSE}
plot(pressure)
```

Note that the `echo = FALSE` parameter was added to the code chunk to prevent printing of the R code that generated the plot.

1
投票

正义

library(tidyverse)

或者你是什么意思?

© www.soinside.com 2019 - 2024. All rights reserved.