相关文章推荐
忧郁的作业本  ·  Ubuntu20.04 ...·  1 年前    · 
Collectives™ on Stack Overflow

Find centralized, trusted content and collaborate around the technologies you use most.

Learn more about Collectives

Teams

Q&A for work

Connect and share knowledge within a single location that is structured and easy to search.

Learn more about Teams

I have compiled R version 2.12.1 (2010-12-16) for my system (CentOS), and afterwards I installed Cairo_1.4-5.

I'd like use Cairo to produce PNG (and maybe PDF) output of my graphs when I batch-invoke my scripts, but this gives me difficulties when I am using X (I am tunneling X through ssh and it often disconnects while the R scripts are running...), so this is why I want to use Cairo.

(I do not have root access btw).

Although it's installed according to sessionInfo

> sessionInfo()
R version 2.12.1 (2010-12-16)
Platform: x86_64-unknown-linux-gnu (64-bit)
locale:
[1] C
attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base

I can not call CairoPDF:

> CairoPDF()
Error: could not find function "CairoPDF"

Weirdly, I can invoke a function called cairo_pdf

> cairo_pdf()

I can not call CairoPNG, cairo_PNG or cairo_png:

> CairoPNG()
Error: could not find function "CairoPNG"
> cairo_PNG()
Error: could not find function "cairo_PNG"
> cairo_png()
Error: could not find function "cairo_png"

Is something wrong withmy installation? Frankly I have no idea how to proceed from here, why can't I even call CairoPNG()?

Your sessionInfo() doesn't indicate that you have Cairo installed. I may be going out of line here, but did you library(Cairo)? – Roman Luštrik Feb 2, 2011 at 11:24 locale: [1] LC_CTYPE=af_ZA.utf8 LC_NUMERIC=C [3] LC_TIME=af_ZA.utf8 LC_COLLATE=af_ZA.utf8 [5] LC_MONETARY=C LC_MESSAGES=af_ZA.utf8 [7] LC_PAPER=af_ZA.utf8 LC_NAME=C [9] LC_ADDRESS=C LC_TELEPHONE=C [11] LC_MEASUREMENT=af_ZA.utf8 LC_IDENTIFICATION=C attached base packages: [1] stats graphics grDevices utils datasets methods base

Then run library(Cairo), if this is not installed

library(Cairo)
Error in library(Cairo) : there is no package called 'Cairo'

This means you will have to install the Cairo R package, which interfaces with the Cairo graphics system

> install.packages('Cairo')

It will download, build and install the package - you don't need root for this

If it was successful, you can run

>library(Cairo)
>sessionInfo()
R version 2.12.1 (2010-12-16)<br>
Platform: i486-pc-linux-gnu (32-bit)
locale:
 [1] LC_CTYPE=af_ZA.utf8       LC_NUMERIC=C             
 [3] LC_TIME=af_ZA.utf8        LC_COLLATE=af_ZA.utf8    
 [5] LC_MONETARY=C             LC_MESSAGES=af_ZA.utf8   
 [7] LC_PAPER=af_ZA.utf8       LC_NAME=C                
 [9] LC_ADDRESS=C              LC_TELEPHONE=C           
 [11] LC_MEASUREMENT=af_ZA.utf8 LC_IDENTIFICATION=C      
attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     
other attached packages:
[1] Cairo_1.4-5
        

Thanks for contributing an answer to Stack Overflow!

  • Please be sure to answer the question. Provide details and share your research!

But avoid

  • Asking for help, clarification, or responding to other answers.
  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.