繁体   English   中英

R markdown 显示控制台 output

[英]R markdown showing console output

我使用带有以下代码的长颈鹿 function 创建了一个交互式 ggplot map

A<-ggplot(data)+geom_sf_interactive(aes(fill=Pop_Rate,tooltip = sprintf("%s<br/>%s", Region,Pop_Rate)))

girafe(code, ggobj = A,
                  options = list(opts_tooltip(use_fill = TRUE),
                                 opts_zoom(min = 1, max = 5),opts_toolbar(saveaspng = FALSE)))

When I add this code to an R markdown flexidashboard, the output includes output from the r console as well as the map

Reading layer Counties_and_Unitary_Authorities__April_2019__Boundaries_EW_BUC' from data source C:\Users\qrs19x\OneDrive - Ministry of Justice\Documents\R\Maps\Shapes\Counties_and_Unitary_Authorities__April_2019__Boundaries_EW_BUC.shp' using driver `ESRI Shapefile' Simple feature collection with 173 features and 10 fields Geometry type: MULTIPOLYGON 尺寸:XY 边界框:xmin:86999.8 ymin:7054.1 xmax:655644.8 ymax:657548.1 投影 CRS:OSGB 1936 / British National Grid

我试过 results=FALSE 但这也将我的“隐藏”隐藏到我的图表中。 目前使用以下

```{r, echo=FALSE, message=FALSE, warning=FALSE}

我没有得到和你一样的 output,因为当你编码时我根本没有得到 output。 话虽如此,我没有您的数据或您可能在 YAML 或块选项中声明的选项。

我很好奇您的代码中的code在做什么。 据我了解,您有codeggobj ,而不是两者。

```{r giraffeMe,echo=F}

library(ggplot2)
library(ggiraph)

nc <- sf::st_read(system.file("shape/nc.shp", package = "sf"), quiet = TRUE)

gg <- ggplot(nc) + 
  geom_sf_interactive(aes(fill = AREA, 
                          tooltip = NAME, 
                          data_id = NAME))
girafe(ggobj = gg,
       options = list(opts_tooltip(use_fill = TRUE),
                      opts_toolbar(saveaspng = FALSE)))
```

这是仪表板中呈现的 map。 我悬停,以便您可以看到工具提示。

在此处输入图像描述

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM