0

I'm having trouble installing the contrib.url package in my RStudio on Windows. Please note that I am using the latest version of RStudio.

I have tried different means via resources I got online and from the R online community but I keep getting this error message:

"A version of this package for your version of R might be available elsewhere, see the ideas at https://cran.r-project.org/doc/manuals/r-patched/R-admin.html#Installing-packages"

I noticed I need this package because I am unable to knit my .Rmd files in HTML and PDF. I was advised to install tinytex and contrib.url. I have been able to install tinytex but couldn't get a way around installing contrib.url.

NelsonGon
  • 13,015
  • 7
  • 27
  • 57

2 Answers2

1

contrib.url is not an R package:

any(grepl("contrib.url", available.packages()))
[1] FALSE

It is a function from the utils package, though (which comes pre-installed):

?contrib.url

It can be used to specify the package type for repository URLs.

jslth
  • 40
  • 3
  • Thanks for your response. So how do I go about knitting my .Rmd files as that's the error I get often while I try to do so? – Olumide Olaoye Nov 22 '21 at 05:41
  • 1
    What exactly is the error you get when knitting .Rmd files? – jslth Nov 22 '21 at 10:31
  • The error I get is this: "A version of this package for your version of R might be available elsewhere, see the ideas at https://cran.r-project.org/doc/manuals/r-patched/R-admin.html#Installing-packages". But I have been able to resolve it now. It happened all I needed too do was comment out all the install.pacckages() functions before knitting the .Rmd files. – Olumide Olaoye Nov 25 '21 at 04:20
  • For future purposes: In rmarkdown documents, you need to specify the cran repository to download packages using `install.packages`. You can either do this by changing `options("repos")` or by passing a `repos` argument to `install.packages`. – jslth Nov 26 '21 at 12:24
0

I have been able to knit the .Rmd file now to HTML. All I needed to do was to just comment out the install.packages() function before knitting and it was successful. Thanks all for your help!

Peter Csala
  • 17,736
  • 16
  • 35
  • 75