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 -- View this message in context: http://www.nabble.com/spss-file-problem-with-foreign-0.8-32-tp22059259p22059259.html Sent from the R help mailing list archive at Nabble.com.
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, > HarryYes, 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
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:> > 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 > -- > View this message in context: http://www.nabble.com/spss-file-problem-with-foreign-0.8-32-tp22059259p22059259.html > Sent from the R help mailing list archive at Nabble.com. > > ______________________________________________ > R-help at r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. >-- 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