Re: [R] write.foreign, SPSS on Mac OS X

From: Prof Brian Ripley <>
Date: Wed 13 Jul 2005 - 16:46:59 EST

On Tue, 12 Jul 2005, EJ Nikelski wrote:

> I have jut installed the foreign package (v 0.8-8) on my OS X
> machine, and have a bit of a problem writing out a data frame in SPSS
> format. Specifically, the code file (the .sps format file) seems to
> write 3 unprintable hex values instead of double quotes. For example, in
> the following output ...
> /
> immDel
> 1 ###1###
> 2 ###2###
> 3 ###3###
> ... emacs tells me that the left-sided ### are the hex codes E2 80 9C,
> on the right we have E2 80 9D. I am supposing that I should be seeing
> double-quotes here? Interestingly, the data file, which also contains a
> quoted field, writes out the quotes without any problem. Does anyone
> have any ideas?

An idea. Those are left and right double quotes in UTF-8 and since MacOS X is usually in a UTF-8 locale they should be printable. However, I suspect that SPSS is expecting ASCII double quotation marks.

You haven't told us what you did, but I guess you used write.foreign(package="SPSS"). That calls writeForeignSPSS which contains calls to dQuote(), and the latter are wrong if ASCII quotation marks are needed.

A quick workaround is to use a non-UTF-8 locale: how you do that on ypur OS depends on how you run R so please ask advice on the R-sig-mac list.

Brian D. Ripley,        
Professor of Applied Statistics,
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595

______________________________________________ mailing list
PLEASE do read the posting guide!
Received on Wed Jul 13 16:55:57 2005

This archive was generated by hypermail 2.1.8 : Fri 03 Mar 2006 - 03:33:36 EST