gpt4 book ai didi

从编织器输出中删除进度条

转载 作者:行者123 更新时间:2023-12-04 12:38:58 25 4
gpt4 key购买 nike

我正在分析一些数据,并想在R上做一个Simpsons悖论。我已经安装了 Simpsons 程序包并加载了库。这是一个基于软件包文档的示例:

---
output: html_document
---
```{r}
library(Simpsons)
#generating data
Coffee1=rnorm(100,100,15)
Neuroticism1=(Coffee1*.8)+rnorm(100,15,8)
g1=cbind(Coffee1, Neuroticism1)
Coffee2=rnorm(100,170,15)
Neuroticism2=(300-(Coffee2*.8)+rnorm(100,15,8))
g2=cbind(Coffee2, Neuroticism2)
Coffee3=rnorm(100,140,15)
Neuroticism3=(200-(Coffee3*.8)+rnorm(100,15,8))
g3=cbind(Coffee3, Neuroticism3)
data2=data.frame(rbind(g1,g2,g3))
colnames(data2) <- c("Coffee","Neuroticism")

example <- Simpsons(Coffee,Neuroticism,data=data2)
plot(example)
```

这将返回一个包含3个簇的图(正是我所需要的)。但是,当我将Rmd文件编织为HTML时,会得到很多等号 (======),其旁边有一个百分比,就像一个加载网格,我希望从最终输出中删除该加载网格。

enter image description here

最佳答案

您可以通过设置knitr chunk选项来抑制R中的任何输出消息。如果我们希望隐藏除绘图以外的所有代码输出,可以使用following solution:

---
output: html_document
---

```{r echo=FALSE, results='hide', fig.keep='all', message = FALSE}
library(Simpsons)
#generating data
Coffee1=rnorm(100,100,15)
Neuroticism1=(Coffee1*.8)+rnorm(100,15,8)
g1=cbind(Coffee1, Neuroticism1)
Coffee2=rnorm(100,170,15)
Neuroticism2=(300-(Coffee2*.8)+rnorm(100,15,8))
g2=cbind(Coffee2, Neuroticism2)
Coffee3=rnorm(100,140,15)
Neuroticism3=(200-(Coffee3*.8)+rnorm(100,15,8))
g3=cbind(Coffee3, Neuroticism3)
data2=data.frame(rbind(g1,g2,g3))
colnames(data2) <- c("Coffee","Neuroticism")

example <- Simpsons(Coffee,Neuroticism,data=data2)
plot(example)
```

我会注意到,该软件包似乎比大多数软件包打印出更多的内容,因此选项的组合相当长。

一种更简单的方法可能是将图移到一个单独的块中,并在其之前运行所有分析。 include参数可用于抑制所有输出,但这包括绘图,因此为什么必须使用两个块:
```{r, include = FALSE}
# your code to build model
```

```{r}
plot(example)
```

Check out the full list of knitr chunk options here

关于从编织器输出中删除进度条,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52834627/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com