R常见错误总结

这篇博客用来记录R常见的错及其器解决办法.

1 系统

1.1 保存ggplot2对象时报错.

使用ggraph画图之后,保存报错.

错误如下:

Error in grid.Call.graphics(C_text, as.graphicsAnnot(x\(label), x\)x, x$y, : invalid font type Traceback:

很明显时字体的错误,但是在set_graph_style以及theme_graph设置字体之后,还是不行,仍然报错.

set_graph_style(family = "Arial")#默认为'Arial Narrow'
theme_graph(base_family = 'Arial')

使用extrafont包导入字体:

extrafont::font_import()

重启R和Rstuio.然后先load字体.

extrafont::loadfonts()

然后画图再保存.

1.2 安装包时报错

错误如下:

ERROR: loading failed for ‘i386’

原因可能如下:

the problem, I think, is that if both 32-bit and 64-bit versions of R are installed, devtools tries to build for both of them. During the build process, it checks if the newly built package can be loaded under both 32-bit and 64-bit R versions. When it tries running the 32-bit version, the reticulate package causes an error if the version of Python it has access to is 64-bit, so the install process fails. I think the key part of the update which spared me this problem was not installing the 32-bit version of R, as now devtools only builds for 64-bit.

解决办法:

add INSTALL_opts=c("--no-multiarch") to your install_github() or BiocManager::install().

Avatar
Xiaotao Shen
Postdoctoral Research Fellow

Metabolomics, Multi-omics, Bioinformatics, Systems Biology.

Related

Next
Previous
comments powered by Disqus