R - knitr - ShareLatex - install.packages(xyz)

时间:2015-01-19 22:32:49

标签: r latex knitr packages sharelatex

如何在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

1 个答案:

答案 0 :(得分:0)

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

  1. 在本地x86_64-pc系统上查找DPI包(例如~/R/x86_64-pc-linux-gnu-library/3.1/DPI
  2. 在sharelatex中创建一个DPI文件夹
  3. 在sharelatex DPI文件夹中上传本地DPI文件夹的内容
  4. 使用DPI
  5. library(DBI)个软件包