[R] Making TIFF images with rtiff

Inman, Brant A. M.D. Inman.Brant at mayo.edu
Fri Jan 12 19:17:49 CET 2007

Several R Helpers pointed out that I forgot to include the dev.off()
statement in my code.  This solved my problem with one caviat: the
output file address cannot have any spaces in it (as pointed out by
Chuck Cleland).  For instance:

# This file location works great
	type = "tifflzw", res = 1200)
plot(speed ~ dist)	

# This file location does not work, despite being accurate
bitmap(file='C:\\Documents and Settings\\m007704\\Desktop\\test.tif',
	type = "tifflzw", res = 1200)
plot(speed ~ dist)	

For the benefit of those that may need to make TIFF files in the future
and don't know how to do it, I will recapitulate below the steps
required to produce a TIFF file using R on a Windows XP machine.

1) Download and install a current version of Ghostscript. 

You probably need GPL(GNU General Public License) version of
Ghostscript. For Windows, the correct file to download is called:
gs854w32-gpl.exe. To download this file, go to one of the following


2) Add Ghostscript to a Windows environmental variable.

Right click on the My Computer icon on your desktop.  Select: Properties
> Advanced > Environmental Variables.  You will see 2 boxes, one for
user variables and one for system variables.  In the user variables
section, highlight the variable called "PATH" and then click edit. Click
on the variable value box and go to the end of whatever is written there
(don't erase it).  Enter the following after the last bit of text:
";C:\Program Files\gs\gs8.54\bin\".  This is the location on you
computer where it can find the gswin32c.exe file that it needs to start

3) Use the bitmap function to produce a TIFF

Now you should be ready to make a TIFF.  The following code is a simple
example that you can use to see if everything is set up right on your

	type = "tifflzw", res = 1200)
plot(speed ~ dist)	

This should produce a TIFF file called 'test.tif' in the 'temp'
directory of your PC.  If you do not have a directory of this name,
substitute for one that exists (or create one).  Note that the file
argument does not seem to handle and spaces in the directory address, so
select an address without spaces in it. Note also that, as pointed out
by Ripley in this thread, there are different TIFF formats which can be
made with R.  My understanding is that the different formats have to do
with different image compression algorithms, but you can read more about
these details (and clues to why TIFF files seem to be prefered by some
publishers and imaging software makers) at:


You can also type ?bitmap to see what R can output for you and read more
about the TIFF file format at:


I regret that I cannot comment on Unix or Mac computers as it has been
nearly 15 years since I have used these types of machines and I
therefore have no knowledge whatsoever that might be of use for users of
these systems.

Brant Inman

More information about the R-help mailing list