[R] write.foreign, SPSS on Mac OS X
Prof Brian Ripley
ripley at stats.ox.ac.uk
Wed Jul 13 08:46:59 CEST 2005
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 ...
>
> VALUE LABELS
> /
> 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, ripley at stats.ox.ac.uk
Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/
University of Oxford, Tel: +44 1865 272861 (self)
1 South Parks Road, +44 1865 272866 (PA)
Oxford OX1 3TG, UK Fax: +44 1865 272595
More information about the R-help
mailing list