0

我正在尝试使用xaringan(an issue with plotly) 来调试特定于操作系统的错误。今天早些时候,我能够在 Linux 和 Mac OS 上使用该软件包创建以下xaringan曼哈顿图,manhattanly但它没有在我家的 Windows 上呈现。

{r, echo = FALSE, results = TRUE, error = FALSE, message=FALSE, fig.width=15, fig.height=5}
if (!requireNamespace("manhattanly")) {
  install.packages("manhattanly")
} else {
  library(manhattanly)
}
manhattanly(HapMap, snp = "SNP", gene = "GENE", highlight = significantSNP)

这是我yaml在 RMarkdown 中的:

---
title: "Main title"
subtitle: "Subtitle"
author: "Matthew J. Oldach"
date: "2019-02-28"
output:
  xaringan::moon_reader:
    lib_dir: libs
    nature:
      highlightStyle: github
      highlightLines: true
      countIncrementalSlides: false
      ratio: 16:9
    css: ["default", "custom.css"]
---

我的选项块:

options(htmltools.dir.version = FALSE)

首先,奇怪的是当我创建标准ggplot图表(或任何有效的 xaringan 幻灯片,例如,leaflet示例)时,我只看到一个大的白色屏幕,左上角有一个小框。但是,当我点击“在浏览器中显示”时,它会显示。另一个 SO 帖子建议运行xaringan::summon_remark()来解决这个问题,但它对我不起作用。

尽管如此,当尝试在 Windows 上查看上面发布的代码时,我在 Firefox 中收到错误/消息:

一个网站正在减慢您的浏览器速度您想做什么?

如果我尝试在 Internet Explorer 中打开它,镀铬同样的东西。正如我之前提到的其他绘图、幻灯片渲染,以及今天早些时候在 Linux 和 Mac OS 上运行的上述内容。

下面是另一个在 Linux 和 Mac OS 上工作但在 Windows 上不工作的情节稍长的例子:

if (!requireNamespace("widgetframe")) {
  install.packages("widgetframe")
} else {
  library(widgetframe)
}
if (!requireNamespace("rgl")) {
  install.packages("rgl")
} else {
  library(rgl)
}
if (!requireNamespace("misc3d")) {
  install.packages("misc3d")
} else {
  library(misc3d)
}
if (!requireNamespace("neurobase")) {
  install.packages("neurobase")
} else {
  library(neurobase)
}
if (!requireNamespace("aal")) {
  devtools::install_github("muschellij2/aal")
} else {
  library(aal)
}
if (!requireNamespace("MNITemplate")) {
  devtools::install_github("jfortin1/MNITemplate")
} else {
  library(MNITemplate)
}

img = aal_image()
template = readMNI(res = "2mm")
cut <- 4500
dtemp <- dim(template)

# All of the sections you can label
labs = aal_get_labels()

# Pick the region of the brain you would like to highlight - in this case the hippocamus_L
hippocampus = labs$index[grep("Hippocampus_L", labs$name)]

mask = remake_img(vec = img %in% hippocampus, img = img)

### this would be the ``activation'' or surface you want to render
contour3d(template, x=1:dtemp[1], y=1:dtemp[2], z=1:dtemp[3], level = cut, alpha = 0.1, draw = TRUE)
contour3d(mask, level = c(0.5), alpha = c(0.5), add = TRUE, color=c("red") )
### add text
text3d(x=dtemp[1]/2, y=dtemp[2]/2, z = dtemp[3]*0.98, text="Top")
text3d(x=-0.98, y=dtemp[2]/2, z = dtemp[3]/2, text="Right")
l <- rglwidget()
frameWidget(l)

非常感谢您的反馈。

sessionInfo()
R version 3.5.2 (2018-12-20)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows >= 8 x64 (build 9200)

Matrix products: default

locale:
[1] LC_COLLATE=English_Canada.1252  LC_CTYPE=English_Canada.1252    LC_MONETARY=English_Canada.1252
[4] LC_NUMERIC=C                    LC_TIME=English_Canada.1252    

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

loaded via a namespace (and not attached):
 [1] compiler_3.5.2  htmltools_0.3.6 tools_3.5.2     xaringan_0.8    yaml_2.2.0     
 [6] Rcpp_1.0.0      rmarkdown_1.11  knitr_1.21      xfun_0.5        digest_0.6.18  
[11] evaluate_0.13
4

0 回答 0