[R] spss-file problem with foreign 0.8-32

Peter Dalgaard P.Dalgaard at biostat.ku.dk
Tue Feb 17 16:57:16 CET 2009


Harry Haupt wrote:
> 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

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).

-- 
   O__  ---- Peter Dalgaard             Øster Farimagsgade 5, Entr.B
  c/ /'_ --- Dept. of Biostatistics     PO Box 2099, 1014 Cph. K
 (*) \(*) -- University of Copenhagen   Denmark      Ph:  (+45) 35327918
~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk)              FAX: (+45) 35327907




More information about the R-help mailing list