Problem:
Using the R to plot the figure and want to store with png file,such as png(file="a.png")
but it will appear
Error in png(file="a.png"): X11 is not available
Solution:
I used the R.2.15.2.1. First you should install the important package for plotting
{
yum install -y cairo-devel.x86_64
yum install -y libpng-devel.x86_64
}
2. configure and compile the R
{
./configure --with-x=no
R is now configured for x86_64-unknown-linux-gnu
Source directory: .
Installation directory:
C compiler: gcc -std=gnu99 -g -O2
Fortran 77 compiler: gfortran -g -O2
C++ compiler: g++ -g -O2
Fortran 90/95 compiler: gfortran -g -O2
Obj-C compiler:
Interfaces supported:
External libraries: readline
Additional capabilities: PNG, TIFF, NLS, cairo
Options enabled: shared BLAS, R profiling, Java
then
make
}
3. Execute the R and check the png is TURE
{
> capabilities()
jpeg png tiff tcltk X11 aqua http/ftp sockets
FALSE TRUE TRUE FALSE FALSE FALSE TRUE TRUE
libxml fifo cledit iconv NLS profmem cairo
TRUE TRUE TRUE TRUE TRUE FALSE TRUE
}
4. Check and setting the bitmapType as cairo in R environment
{
>options(bitmapType="cairo")
}
Reference:
unable to start PNG / X11 in rstudioHow to get R to compile with PNG support
R install
R dowload
Centos x11