4

如何在 ShareLatex knitr 文件 (.Rtex) 中安装软件包?R代码

par(mfrow=c(1,1))
install.packages("tree")
library(tree)
model.tree.simpel <- tree(response~.,data=dat)
plot(model.tree.simpel)
text(model.tree.simpel)

错误信息

Installing package into '/usr/local/lib/R/site-library'## (as 'lib' is unspecified)##
Warning in install.packages("tree"):
'lib = "/usr/local/lib/R/site-library"' is notwritable##
Error in install.packages("tree"):  unable to install packages##
Error in library(tree):  there is no package called 'tree'##
Error in eval(expr, envir, enclos):  could not find function "tree"##
Error in plot(model.tree.simpel):  object 'model.tree.simpel' not found##
Error in text(model.tree.simpel):  object 'model.tree.simpel' not found
4

1 回答 1

0

似乎您无法安装软件包,但可以上传它们。我在这里以DPI包为例。似乎官方的 sharelatex 服务器运行在 linux x86_64 机器上。所以你的包需要在这样的机器上编译(例如 ubunut 64)

  1. 在本地 x86_64-pc 系统上找到 DPI 包(例如~/R/x86_64-pc-linux-gnu-library/3.1/DPI
  2. DPI在sharelatex中创建一个文件夹
  3. 将本地DPI文件夹的内容上传到 sharelatexDPI文件夹中
  4. 使用该DPI软件包library(DBI)
于 2015-05-27T22:02:38.703 回答