“当”时,生成带有R减价的地块;针织“;到html

“当”时,生成带有R减价的地块;针织“;到html,html,r,ggplot2,markdown,knitr,Html,R,Ggplot2,Markdown,Knitr,更新:我用一些愚蠢的方法解决了这个问题。我必须在绘图的代码块之前包含一个行空间,然后它就如我所希望的那样工作了。感谢您抽出时间回答这个问题。 我有一个降价文档,当我“编织”到Word或pdf时,它可以完美地工作。然而,当我“编织”到html时,没有任何绘图出现。在堆栈溢出方面也有类似的问题,但我找不到与此类似的问题 这是我试图在代码块中使用的指令(它不起作用): 但是,当我将指令设置为此时,我得到了绘图: {r, emotional circumplex, fig.align = "center

更新:我用一些愚蠢的方法解决了这个问题。我必须在绘图的代码块之前包含一个行空间,然后它就如我所希望的那样工作了。感谢您抽出时间回答这个问题。

我有一个降价文档,当我“编织”到Word或pdf时,它可以完美地工作。然而,当我“编织”到html时,没有任何绘图出现。在堆栈溢出方面也有类似的问题,但我找不到与此类似的问题

这是我试图在代码块中使用的指令(它不起作用):

但是,当我将指令设置为此时,我得到了绘图:

{r, emotional circumplex, fig.align = "center", echo=TRUE}
问题是,我不想在html文档中生成代码,只想生成绘图

我尝试了“股票”降价示例,如下所示,但该示例也没有出现在html文档中:

```{r pressure, echo=FALSE}
plot(pressure)
```
这是YAML信息:

---
title: "HTML TEST"
author: "Pete Miksza"
date: "12/12/2017"
output: html_document
---
这是不可复制的,但这是我实际绘图的代码块:

```{r, emotional circumplex, fig.align = "center", echo=FALSE}
# Emotional Circumplex
ggplot(charlie_brown_dat, aes(x = scale(energy), y = scale(valence))) + 
  geom_point(aes(size = Tempo, shape = PopularitySplit), color = "darkgreen") +
  geom_hline(yintercept = 0, color = "red") +
  geom_vline(xintercept = 0, color = "red") +
  geom_label_repel(aes(label = track_name), size = 1.7, point.padding = .75) +
  scale_x_continuous(limits = c(-2.5, 2.5)) +
  scale_y_continuous(limits = c(-2.5, 2.5)) +
  labs(title = "Where do the Tracks Sit on an Emotion Circumplex?", 
       x = "\nValence \n(- negative to + positive)", y = "\nArousal \n(- low energy to + high energy)") +  
  theme(axis.text.x = element_text(size = 8),
        axis.text.y = element_text(size = 8),
        axis.title.x = element_text(size = 9, face = "italic"),
        axis.title.y = element_text(size = 9, face = "italic"),
        axis.line = element_blank(),
        axis.ticks = element_blank(),
        plot.title = element_text(size = 11, face = "bold"),
        legend.title = element_text(size = 8),
        legend.key.size =  unit(.05, "in"),
        legend.text = element_text(size = 6.5),
        panel.background = element_rect(fill = "white"),
        panel.grid.major = element_line(color = "lightgray"))
```
我没有收到任何警告消息,但这包含在我的控制台中的降价输出中:

/Applications/RStudio.app/Contents/MacOS/pandoc/pandoc +RTS -K512m -RTS Music_from_a_Charlie_Brown_Christmas.utf8.md --to html --from markdown+autolink_bare_uris+ascii_identifiers+tex_math_single_backslash --output Music_from_a_Charlie_Brown_Christmas.html --smart --email-obfuscation none --self-contained --standalone --section-divs --template /Users/pmiksza/Library/R/3.4/library/rmarkdown/rmd/h/default.html --no-highlight --variable highlightjs=1 --variable 'theme:bootstrap' --include-in-header /var/folders/pw/1hpqdrzn5853ys3whns5mg34vh62tx/T//RtmpOt8rhU/rmarkdown-str1dc15577eea.html --mathjax --variable 'mathjax-url:https://mathjax.rstudio.com/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML' 

作为一个快速的临时修复,可以将绘图保存为.jpg文件,然后将图像读取到RMarkdown文件中

下面是一个例子:

```{r, echo=FALSE}
library(jpeg)

img <- readJPEG('cat.jpeg')

plot(1:2, type='n')
graphics::rasterImage(img,1,1,2,2)
```
`{r,echo=FALSE}
图书馆(jpeg)

img股票示例中未显示的曲线图是奇数。在创建股票示例时(在控制台的RMarkdown选项卡中),您是否在日志中看到任何警告或错误?此外,我认为区块名称应该出现在第一个逗号之前,并且不应该包含空格,例如
{r emotional\u contracplex,fig.align=“center”,echo=FALSE}
。但不确定这是否能解决任何问题。knitr输出日志中显示了哪些错误?YAML标题中有什么?正在设置的其他knitr设置中有哪些未显示?马吕斯是正确的,因为在名字中使用空格不是一个好主意。你在用什么操作系统?等等。需要更多信息。感谢您参与此问题,我已编辑了我的原始问题,并对这些评论进行了回复。感谢您提供此解决方案。
```{r, echo=FALSE}
library(jpeg)

img <- readJPEG('cat.jpeg')

plot(1:2, type='n')
graphics::rasterImage(img,1,1,2,2)
```