我有一个.Rmd文件,我试图通过函数pandoc创建一个.docx文件.
我希望有一个最终分辨率为504x504像素的数字(即7x7英寸,72dpi).不幸的是,默认的72 dpi质量太差了,我想把它增加到150 dpi而不改变最终分辨率(所以它在.docx文件中已经有了正确的大小).如果我保留选项fig.width和fig.height = 7并设置dpi = 150,我得到我想要的质量,但最终分辨率增加,数字超出.docx边距.我尝试使用out.width和out.height参数进行播放,但是当我包含它们时,它只是在最终的.docx中没有绘制任何内容.
想法?
My title
-------------------------
*(this report was produced on: `r as.character(Sys.Date())`)*
That's my plot
```{r echo=FALSE}
plot(0,0,type="n",xlim=c(0,500), ylim=c(-12,0), las=1)
color <- rainbow(500)
text(380,-1,"Test",pos=4)
lseq <- seq(-6,-2,length.out=500)
for(j in seq_along(lseq)) {
lines(c(400,450), rep(lseq[j], 2), col=color[j])
}
polygon(c(400,450,450,400), c(-6,-6,-2,-2), lwd=1.2)
```
Run Code Online (Sandbox Code Playgroud)
library(knitr)
library(markdown)
knit("example.Rmd") # produces the md file
pandoc("example.md", format = "docx") #prodces the .docx file
Run Code Online (Sandbox Code Playgroud)
如果我尝试重新缩放图形,它就不起作用.下面:
My title
-------------------------
*(this report was produced on: `r as.character(Sys.Date())`)*
That's my plot
```{r …Run Code Online (Sandbox Code Playgroud) 我想使用以太平洋地区(特别是澳大利亚)为中心的 Mollweide 投影,使用 rnaturalearth--> sf-->ggplot管道在 R 中绘制世界地图。
我遇到了一个恼人的问题,即在全球范围内连接线路。
从新的 R 会话中,我运行
library(tidyverse)
library(rnaturalearth)
library(rnaturalearthdata)
library(sf)
target_crs <- st_crs("+proj=moll +x_0=0 +y_0=0 +lat_0=0 +lon_0=133")
worldrn <- ne_countries(scale = "medium", returnclass = "sf") %>%
sf::st_transform(crs = target_crs)
ggplot(data = worldrn, aes(group = admin)) +
geom_sf()
Run Code Online (Sandbox Code Playgroud)
生成这个图
这是我的sessionInfo():
R version 4.1.0 (2021-05-18)
Platform: x86_64-apple-darwin17.0 (64-bit)
Running under: macOS Catalina 10.15.7
Matrix products: default
BLAS: /Library/Frameworks/R.framework/Versions/4.1/Resources/lib/libRblas.dylib
LAPACK: /Library/Frameworks/R.framework/Versions/4.1/Resources/lib/libRlapack.dylib
locale:
[1] en_AU.UTF-8/en_AU.UTF-8/en_AU.UTF-8/C/en_AU.UTF-8/en_AU.UTF-8
attached base packages:
[1] stats graphics grDevices utils …Run Code Online (Sandbox Code Playgroud)