简体   繁体   English

RStudio 新手,编织到 HTML 的问题

[英]New to RStudio, issues with knit to HTML

I'm new to RStudio and programming in general.我是 RStudio 和编程的新手。 When I click on knit to HTML I get this error message.当我单击 knit to HTML 时,我收到此错误消息。 How can I fix this?我怎样才能解决这个问题?

Quitting from lines 231-248 (lesson3_student.rmd) 
Error in contrib.url(repos, "source") : 
  trying to use CRAN without setting a mirror
Calls: <Anonymous> ... withVisible -> eval -> eval -> install.packages -> contrib.url

The error message should be fixed, when you set a mirror as argument of the install.packages function:当您将镜像设置为install.packages函数的参数时,应该修复错误消息:

install.packages("imputeTS",repos = "https://cloud.r-project.org/")

As mentioned in the comments, you only need to install packages once.正如评论中提到的,您只需要安装一次软件包。 So you do not necessarily need to do this in the .Rmd document.因此,您不一定需要在 .Rmd 文档中执行此操作。

Potential user of your .Rmd document will probably see the library("package") calls at the beginning and install the packages on their own. .Rmd 文档的潜在用户可能会在开头看到library("package")调用并自行安装包。

If you still want to include the install.packages you can do something like this to load the package and only install if necessary:如果你仍然想包含install.packages你可以做这样的事情来加载包,只在必要时安装:

if(!require("ridge"))  {
   install.packages("ridge",repos = "https://cloud.r-project.org/")
}

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

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