[R] exporting data frame - write foreign inconsistencies

John Cullen jcullen at caninesinmotion.com
Wed Jan 13 16:58:14 CET 2010


Hello List,

I have a data frame object (wa2) that I am exporting for use in
another statistics package. Using

library(foreign)
write.foreign(wa2, choose.files(), choose.files(), package='SPSS')

I noticed that there were several differences between the data sets as
seen within R (View(wa2)) and what was produced in SPSS.  Examining
the data file produced by write.foreign (before running the generated
SPSS syntax), I noticed the same inconsistencies.

I then used:

write.table(wa2, choose.files(), sep=",", col.names=TRUE,
row.names=FALSE, quote=TRUE, na="NA")

and the file generated using this method matched what was in the R object.
I'm trying to send this dataset to a colleague who will only use SPSS.
Any ideas why the two methods produce different data files?

--
sessionInfo()
R version 2.10.1 (2009-12-14)
i386-pc-mingw32

locale:
[1] LC_COLLATE=English_Canada.1252  LC_CTYPE=English_Canada.1252
[3] LC_MONETARY=English_Canada.1252 LC_NUMERIC=C
[5] LC_TIME=English_Canada.1252

attached base packages:
[1] tcltk     stats     graphics  grDevices utils     datasets  methods
[8] base

other attached packages:
[1] Rcmdr_1.5-4    car_1.2-16     relimp_1.0-1   foreign_0.8-39

loaded via a namespace (and not attached):
[1] tools_2.10.1
--

Thanks in advance.

Sincerely;

John Cullen, M.Sc.
caninesinmotion.com



More information about the R-help mailing list