Skip to content

spss-file problem with foreign 0.8-32

4 messages · Harry Haupt, Peter Dalgaard, Brian Ripley

#
Hi,
after updating to foreign version 0.8-32, I experienced the following error
when I tried to load a SPSS file:

Fehler in inherits(x, "factor") : objekt "cp" nicht gefunden
Zus?tzlich: Warning message:
In read.spss("***l.sav", use.value.labels = TRUE, to.data.frame = TRUE) :
  ***.sav: File-indicated character representation code (1252) looks like a
Windows codepage

It worked without problems with earlier versions.

Thanks for any clues,
best,
Harry
#
Harry Haupt wrote:
Yes, something in the logic appears to have gotten garbled.

It's in this part of read,spss:

    if (is.character(reencode)) {
        cp <- reencode
        reencode <- TRUE
    }
    else if (codepage <= 500 || codepage >= 2000) {
        attr(rval, "codepage") <- NULL
        reencode <- FALSE
    }
    else if (m <- match(cp, knownCP, 0L))
        cp <- names(knownCP)[m]

if you get to the 2nd "else if" then cp is unset. Possible the attempted
match should be of codepage? But it still looks wrong: Why restrict to
codepages between 500 and 2000 when knownCP contains several values
above 10000???

A workaround is to set reencode="ascii" (or whatever is relevant).
#
Peter Dalgaard wrote:
Dear Peter,
thanks, reencode="ascii" fixed it (and leaves just the warning message,
which seems to have no effect).
Best,
Harry

-----
---
Centre for Statistics
Bielefeld University, Germany
#
It is a issue specific to 0.8-32 and some files (most likely those 
with some (not all) Windows codepages declared).

We are trying to collect together some examples, and will update 
foreign accordingly later in the week.
On Tue, 17 Feb 2009, Harry Haupt wrote: