0

When I started R it came with the following Error

Error in alpha(fill, alpha) : could not find function "col2rgb"

when I try to compile PDF in knitr I get the same error:

Error in alpha(fill, alpha) : could not find function "col2rgb" Calls: .First ... grob -> gpar -> validGP -> numnotnull -> match -> alpha Execution halted

I don't know how to isolate this problem, since it last I used R and no when I start it produces the error. From what I can gather the col2rgb should be in the base package {grDevices}

library(grDevices)
grDevices::col2rgb("white")
  [,1]
red    255
green  255
blue   255

Which seems to work fine. The error is independent of knitr

Anyone know a fix, or can give any suggestion as to how to isolate the problem?

Best Regards

UseR10085
  • 7,120
  • 3
  • 24
  • 54
Timo Kvamme
  • 2,806
  • 1
  • 19
  • 24
  • 2
    possible duplicate of [Knitr: R package check error, object 'opts\_chunk' not found](http://stackoverflow.com/questions/16752765/knitr-r-package-check-error-object-opts-chunk-not-found) – jeremycg Aug 13 '15 at 14:04
  • tried setting require('knitr') library(knitr) before opts_chuck. Still nothing, and it does still report the error without running compilePDF – Timo Kvamme Aug 13 '15 at 14:09

2 Answers2

2

You must have saved your workspace. Almost all experienced R users never do this.... so don't do that in the future. For now, you'd find an .Rdata or .RData or similar in your working directory/folder and rename it (so if it contains important stuff you can still load(.) it manually afterward. After that, starting R should not give your message anymore (the grDevices package is one of the packages that are always loaded in R ((unless you specifically disable that; which may even be difficult in RStudio))).

Martin Mächler
  • 4,619
  • 27
  • 27
0

Found it!

It was due to a source("") of some often used functions that was sourced at startup via the .Rprofile. when i moved the sourcing to after Rstudio had fully started it works - even knitr.

Timo Kvamme
  • 2,806
  • 1
  • 19
  • 24