Skip to content
Prev 170770 / 398506 Next

spss-file problem with foreign 0.8-32

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