diff -Nru foreign-0.8.67/ChangeLog foreign-0.8.69/ChangeLog --- foreign-0.8.67/ChangeLog 2016-09-13 09:57:27.000000000 +0000 +++ foreign-0.8.69/ChangeLog 2017-06-21 11:44:51.000000000 +0000 @@ -1,3 +1,85 @@ +2017-06-21 Uwe Ligges + + * DESCRIPTION: Version is 0.8-69 + * add more sophisticated test cases and new examples for read.spss + +2017-06-20 Uwe Ligges + + * R/spss.R: + - fix for R >= 3.4.0 not allowing duplicated factor labels, hence new arguments + duplicated.value.labels and duplicated.value.labels.infix + that control whether to make factor labels unique or to condence + all levels with identical factor labels into one level + - new argument add.undeclared.levels: Many files observed in the wild + have variables with one or more value labels and further + non-missing values that have no value label. + We cann now sepcify whether the other levels should be appended or sorted + into the declared labels, or not to convert to factor at all. + This fixes several issues, e.g. that values without labels were + regarded as NA values before. + +2017-06-19 Uwe Ligges + + * R/spss.R: + - allow to pass a "..." argument to as.data.frame, + add argument "sub" for substituting invalid chars rather than returning NAs and + allowing for back compatibility + - now also auto-reencodes if R is ruinning in a latin-1 locale and sav file's encoding is not. + * src/sfm-read.c: Update for format type 7 subtypes: + - more comments and restructured + - information from + https://www.gnu.org/software/pspp/pspp-dev/html_node/System-File-Format.html#System-File-Format + - no longer warns for subtypes 12, 17, 18, 19, 20, 24 as these can be safely ignored + - more informative warning messages for subtypes 14, 21, 22 (long strings) + +2017-06-12 Uwe Ligges + + * R/spss.R: use iconv(..., sub=".") so that character labels/names/values + with invalid or non convertible chars are no longer silently coerced to NA + +2017-06-09 Uwe Ligges + + * src/sfm-read.c: Do not evaluate the write field for the format + type any more as this produces errors and given + https://www.gnu.org/software/pspp/pspp-dev/html_node/Variable-Record.html#Variable-Record + tells us on June 9, 2017: + "A few system files have been observed in the wild with invalid write fields, + in particular with value 0. Readers should probably treat invalid print or + write fields as some default format. " + +2017-05-04 Uwe Ligges + + * several bugfixes for writeForeignSPSS: + add/correct declaration of factors and ordered factors (nominal, ordered); + add/correct declaration of numeric (scale) variables; + calculate length of character variables correctly, even if + all entries are NA and there is no longer a 255 char limit + (since SPSS 13); + data files are typically encoded in the current locale and not always ASCII; + variable name list must not exceed 251 chars for each line of code + and had to be wrapped + +2017-04-29 Uwe Ligges + + * add maxchars = 32L argument to writeForeignSPSS + in order to allow for longer variable names for SPSS versions > 12 + * bugfix in writeForeignSPSS for declaration of character variables by prefixed stars + +2017-04-27 Uwe Ligges + + * writeForeignCode.R: SET DECIMAL=DOT. in SPSS required if + it runs in a locale with DECIMAL=comma + +2017-04-22 Uwe Ligges + + * DESCRIPTION: Version is 0.8-68 + * src/sfm-read.c: no longer convert variable name characters to upper case nor give warnings + (as this fails in multi byte encodings and seems not to be required) + +2016-09-24 Brian Ripley + + * man/read.dta.Rd: mention package 'haven'. + 2016-09-13 Kurt Hornik * DESCRIPTION: Version is 0.8-67 diff -Nru foreign-0.8.67/debian/changelog foreign-0.8.69/debian/changelog --- foreign-0.8.67/debian/changelog 2017-06-22 16:30:15.000000000 +0000 +++ foreign-0.8.69/debian/changelog 2017-06-22 16:30:15.000000000 +0000 @@ -1,8 +1,23 @@ -foreign (0.8.67-1trusty0) trusty; urgency=medium +foreign (0.8.69-1trusty0) trusty; urgency=medium - * Compilation for Ubuntu 14.04.4 LTS + * Compilation for Ubuntu 14.04.5 LTS - -- Michael Rutter Fri, 07 Oct 2016 20:22:51 +0000 + -- Michael Rutter Thu, 22 Jun 2017 15:37:06 +0000 + +foreign (0.8.69-1) unstable; urgency=medium + + * New upstream release + + -- Dirk Eddelbuettel Wed, 21 Jun 2017 15:00:17 -0500 + +foreign (0.8.68-1) unstable; urgency=medium + + * New upstream release + + * debian/control: Set Build-Depends: to current R version + * debian/control: Add Depends: on ${misc:Depends} + + -- Dirk Eddelbuettel Mon, 24 Apr 2017 12:22:33 -0500 foreign (0.8.67-1) unstable; urgency=medium diff -Nru foreign-0.8.67/debian/control foreign-0.8.69/debian/control --- foreign-0.8.67/debian/control 2017-06-22 16:30:15.000000000 +0000 +++ foreign-0.8.69/debian/control 2017-06-22 16:30:15.000000000 +0000 @@ -2,12 +2,12 @@ Section: gnu-r Priority: optional Maintainer: Dirk Eddelbuettel -Build-Depends: debhelper (>= 7.0.0), r-base-dev (>= 3.3.1), cdbs +Build-Depends: debhelper (>= 7.0.0), r-base-dev (>= 3.4.0), cdbs Standards-Version: 3.9.8 Package: r-cran-foreign Architecture: any -Depends: ${shlibs:Depends}, ${R:Depends} +Depends: ${shlibs:Depends}, ${misc:Depends}, ${R:Depends} Replaces: r-recommended (<< 1.9.0) Description: GNU R package to read/write data from other stat. systems This package provides functions for reading and writing data stored by diff -Nru foreign-0.8.67/DESCRIPTION foreign-0.8.69/DESCRIPTION --- foreign-0.8.67/DESCRIPTION 2016-09-13 11:04:33.000000000 +0000 +++ foreign-0.8.69/DESCRIPTION 2017-06-21 18:03:34.000000000 +0000 @@ -1,9 +1,9 @@ Package: foreign Priority: recommended -Version: 0.8-67 -Date: 2016-09-12 -Title: Read Data Stored by Minitab, S, SAS, SPSS, Stata, Systat, Weka, - dBase, ... +Version: 0.8-69 +Date: 2017-06-21 +Title: Read Data Stored by 'Minitab', 'S', 'SAS', 'SPSS', 'Stata', + 'Systat', 'Weka', 'dBase', ... Depends: R (>= 3.0.0) Imports: methods, utils, stats Authors@R: c( @@ -14,6 +14,7 @@ person("Saikat", "DebRoy", role = c("ctb", "cph")), person("Stephen", "Eglen", role = c("ctb", "cph")), person("Rajarshi", "Guha", role = c("ctb", "cph")), + person("Swetlana", "Herbrandt", role = "ctb"), person("Nicholas", "Lewin-Koh", role = c("ctb", "cph")), person("Mark", "Myatt", role = c("ctb", "cph")), person("Ben", "Pfaff", role = "ctb"), @@ -22,21 +23,22 @@ person("Stephen", "Weigand", role = c("ctb", "cph")), person("Free Software Foundation, Inc.", role = "cph")) Copyright: see file COPYRIGHTS -Description: Functions for reading and writing data stored by some versions of - Epi Info, Minitab, S, SAS, SPSS, Stata, Systat and Weka - and for reading and writing some dBase files. +Description: Reading and writing data stored by some versions of + 'Epi Info', 'Minitab', 'S', 'SAS', 'SPSS', 'Stata', 'Systat', 'Weka', + and for reading and writing some 'dBase' files. ByteCompile: yes Biarch: yes License: GPL (>= 2) BugReports: https://bugs.r-project.org NeedsCompilation: yes -Packaged: 2016-09-13 10:12:04 UTC; hornik +Packaged: 2017-06-21 15:59:59 UTC; ligges Author: R Core Team [aut, cph, cre], Roger Bivand [ctb, cph], Vincent J. Carey [ctb, cph], Saikat DebRoy [ctb, cph], Stephen Eglen [ctb, cph], Rajarshi Guha [ctb, cph], + Swetlana Herbrandt [ctb], Nicholas Lewin-Koh [ctb, cph], Mark Myatt [ctb, cph], Ben Pfaff [ctb], @@ -46,4 +48,4 @@ Free Software Foundation, Inc. [cph] Maintainer: R Core Team Repository: CRAN -Date/Publication: 2016-09-13 13:04:33 +Date/Publication: 2017-06-21 18:03:34 UTC Binary files /tmp/tmpUk6gBr/2u58pHhyRV/foreign-0.8.67/inst/files/electric.sav and /tmp/tmpUk6gBr/03HMaNbG2m/foreign-0.8.69/inst/files/electric.sav differ Binary files /tmp/tmpUk6gBr/2u58pHhyRV/foreign-0.8.67/inst/files/testdata.sav and /tmp/tmpUk6gBr/03HMaNbG2m/foreign-0.8.69/inst/files/testdata.sav differ diff -Nru foreign-0.8.67/man/read.dta.Rd foreign-0.8.69/man/read.dta.Rd --- foreign-0.8.67/man/read.dta.Rd 2015-02-11 11:12:18.000000000 +0000 +++ foreign-0.8.69/man/read.dta.Rd 2017-03-31 12:09:02.000000000 +0000 @@ -89,7 +89,7 @@ \seealso{ A different approach is available in package \pkg{memisc}: see its help for \code{Stata.file}, at the time of writing not for Stata 12 or - later. + later. Or \code{read_dta} in package \pkg{haven}. Package \pkg{readstata13} for Stata 13 files. diff -Nru foreign-0.8.67/man/read.spss.Rd foreign-0.8.69/man/read.spss.Rd --- foreign-0.8.67/man/read.spss.Rd 2015-02-15 16:29:32.000000000 +0000 +++ foreign-0.8.69/man/read.spss.Rd 2017-06-21 10:16:26.000000000 +0000 @@ -14,7 +14,10 @@ \usage{ read.spss(file, use.value.labels = TRUE, to.data.frame = FALSE, max.value.labels = Inf, trim.factor.names = FALSE, - trim_values = TRUE, reencode = NA, use.missings = to.data.frame) + trim_values = TRUE, reencode = NA, use.missings = to.data.frame, + sub = ".", add.undeclared.levels = c("sort", "append", "no"), + duplicated.value.labels = c("append", "condense"), + duplicated.value.labels.infix = "_duplicated_", ...) } \arguments{ \item{file}{character string: the name of the file or URL to read.} @@ -30,12 +33,42 @@ \item{trim_values}{logical: should values and value labels have trailing spaces ignored when matching for \code{use.value.labels = TRUE}?} \item{reencode}{logical: should character strings be re-encoded to the - current locale. The default, \code{NA}, means to do so in a UTF-8 - locale, only. Alternatively a character string specifying an encoding to + current locale. The default, \code{NA}, means to do so in UTF-8 or latin-1 + locales, only. Alternatively a character string specifying an encoding to assume for the file.} \item{use.missings}{logical: should information on user-defined missing values be used to set the corresponding values to \code{NA}?} -} + \item{sub}{character string: If not \code{NA} it is used by \code{\link{iconv}} + to replace any non-convertible bytes in character/factor input. + Default is \code{"."}. For back compatibility with \pkg{foreign} + versions <= 0.8-68 use \code{sub=NA}.} + \item{add.undeclared.levels}{character: + specify how to handle variables with at least one value label and further + non-missing values that have no value label (like a factor levels in R). + For \code{"sort"} (the default) it adds undeclared factor levels to the + already declared levels (and labels) and sort them according to level, + for \code{"append"} it appends undeclared factor levels to declared levels + (and labels) without sorting, and + for \code{"no"} this does not convert to factor in case of numeric SPSS levels + (not labels), and still converts to factor if the SPSS levels are characters + and \code{to.data.frame=TRUE}. + For back compatibility with \pkg{foreign} versions <= 0.8-68 use + \code{add.undeclared.levels="no"} (not recommended as this may convert some + values with missing corresponding value labels to \code{NA}).} + \item{duplicated.value.labels}{character: what to do with duplicated value + labels for different levels. + For \code{"append"} (the default), the first original value label is kept + while further duplicated labels are renamed to + \code{paste0(label, duplicated.value.labels.infix, level)}, + for \code{"condense"}, all levels with identical labels are condensed into + exactly the first of these levels in R. + Back compatibility with \pkg{foreign} versions <= 0.8-68 is not given as + R versions >= 3.4.0 no longer support duplicated factor labels. + } + \item{duplicated.value.labels.infix}{character: the infix used for labels of + factor levels with duplicated value labels in SPSS (default \code{"_duplicated_"}) + if \code{duplicated.value.labels="append"}.} + \item{...}{passed to \code{\link{as.data.frame}} if \code{to.data.frame = TRUE}.}} \value{ A list (or optionally a data frame) with one component for each variable in the saved data set. @@ -79,10 +112,7 @@ data), and you will not want these variables converted to factors. By setting \code{max.value.labels} you can specify that variables with a large number of distinct values are not converted to factors even if - they have value labels. In addition, variables will not be converted - to factors if there are non-missing values that have no value label. - The value labels are then returned in the \code{"value.labels"} - attribute of the variable. + they have value labels. If SPSS variable labels are present, they are returned as the \code{"variable.labels"} attribute of the answer. @@ -99,7 +129,7 @@ provides a list of translations from Windows codepage numbers to encoding names that \code{\link{iconv}} is likely to know about and so suitable values for \code{reencode}. Automatic re-encoding is - attempted for apparent codepages of 200 or more in a UTF-8 locale: + attempted for apparent codepages of 200 or more in a UTF-8 or latin-1 locale: some other high-numbered codepages can be re-encoded on most systems, but the encoding names are platform-dependent (see \code{\link{iconvlist}}). @@ -114,7 +144,7 @@ which need re-encoding. The most common occurrence is Windows codepage 1252, a superset of Latin-1. The encoding is recorded (as an integer) in attribute \code{"codepage"} of the result if it looks like a - Windows codepage. Automatic re-encoding is done only in UTF-8 + Windows codepage. Automatic re-encoding is done only in UTF-8 and latin-1 locales: see argument \code{reencode}. } \author{Saikat DebRoy and the R-core team} @@ -123,13 +153,61 @@ package \pkg{memisc}: see its help for \code{spss.system.file}. } \examples{ -\dontrun{## if you have an SPSS file called 'datafile': -read.spss("datafile") -## don't convert value labels to factor levels -read.spss("datafile", use.value.labels = FALSE) -## convert value labels to factors for variables with at most -## ten distinct values. -read.spss("datafile", max.value.labels = 10) -} +(sav <- system.file("files", "electric.sav", package = "foreign")) +dat <- read.spss(file=sav) +str(dat) # list structure with attributes + +dat <- read.spss(file=sav, to.data.frame=TRUE) +str(dat) # now a data.frame + + +### Now we use an example file that is not very well structured and +### hence may need some special treatment with appropriate argument settings. +### Expect lots of warnings as value labels (corresponding to R factor labels) are uncomplete, +### and an unsupported long string variable is present in the data +(sav <- system.file("files", "testdata.sav", package = "foreign")) + +### Examples for add.undeclared.levels: +## add.undeclared.levels = "sort" (default): +x.sort <- read.spss(file=sav, to.data.frame = TRUE) +## add.undeclared.levels = "append": +x.append <- read.spss(file=sav, to.data.frame = TRUE, + add.undeclared.levels = "append") +## add.undeclared.levels = "no": +x.no <- read.spss(file=sav, to.data.frame = TRUE, + add.undeclared.levels = "no") + +levels(x.sort$factor_n_undeclared) +levels(x.append$factor_n_undeclared) +str(x.no$factor_n_undeclared) + + +### Examples for duplicated.value.labels: +## duplicated.value.labels = "append" (default) +x.append <- read.spss(file=sav, to.data.frame=TRUE) +## duplicated.value.labels = "condense" +x.condense <- read.spss(file=sav, to.data.frame=TRUE, + duplicated.value.labels = "condense") + +levels(x.append$factor_n_duplicated) +levels(x.condense$factor_n_duplicated) + +as.numeric(x.append$factor_n_duplicated) +as.numeric(x.condense$factor_n_duplicated) + + +## Long Strings (>255 chars) are imported in consecutive separate variables +## (see warning about subtype 14): +x <- read.spss(file=sav, to.data.frame=TRUE, stringsAsFactors=FALSE) + +cat.long.string <- function(x, w=70) cat(paste(strwrap(x, width=w), "\n")) + +## first part: x$string_500: +cat.long.string(x$string_500) +## second part: x$STRIN0: +cat.long.string(x$STRIN0) +## complete long string: +long.string <- apply(x[,c("string_500", "STRIN0")], 1, paste, collapse="") +cat.long.string(long.string) } \keyword{file} diff -Nru foreign-0.8.67/man/write.dbf.Rd foreign-0.8.69/man/write.dbf.Rd --- foreign-0.8.67/man/write.dbf.Rd 2007-07-28 14:32:53.000000000 +0000 +++ foreign-0.8.69/man/write.dbf.Rd 2017-03-31 12:09:02.000000000 +0000 @@ -81,7 +81,7 @@ in2 <- read.dbf(try2) str(in2) unlink(c(try1, try2)) -\testonly{ +\dontshow{ DF <- data.frame(a=c(1:3, NA), b=c(NA, rep(pi, 3)), c=c(TRUE,NA, FALSE, TRUE), d=c("aa", "bb", NA, "dd"), e=I(c("a1", NA, NA, "a4"))) diff -Nru foreign-0.8.67/man/write.foreign.Rd foreign-0.8.69/man/write.foreign.Rd --- foreign-0.8.67/man/write.foreign.Rd 2011-12-03 15:17:02.000000000 +0000 +++ foreign-0.8.69/man/write.foreign.Rd 2017-04-28 12:41:09.000000000 +0000 @@ -40,6 +40,17 @@ and \code{libpath = NULL} taking a string that will be the directory where the target SAS datset will be written when the generated SAS code been run. + + +For \code{package="SPSS"} there is an optional argument \code{maxchars = 32L} +taking an integer that causes the variable names (not variable labels) +to be abbreviated to not more than \code{maxchars} chars. +For compatibility with SPSS version 12 and before, change this to \code{maxchars = 8L}. +In single byte locales with SPSS versions 13 or later, this can be set to \code{maxchars = 64L}. + +For \code{package="SPSS"}, as a side effect, the decimal indicator is always set by +\code{SET DECIMAL=DOT.} which may override user settings of the indicator or its default +derived from the current locale. } \value{ Invisible \code{NULL}. @@ -49,9 +60,9 @@ Thomas Lumley and Stephen Weigand } \examples{\dontrun{ -datafile<-tempfile() -codefile<-tempfile() -write.foreign(esoph,datafile,codefile,package="SPSS") +datafile <- tempfile() +codefile <- tempfile() +write.foreign(esoph, datafile, codefile, package="SPSS") file.show(datafile) file.show(codefile) unlink(datafile) diff -Nru foreign-0.8.67/MD5 foreign-0.8.69/MD5 --- foreign-0.8.67/MD5 2016-09-13 11:04:33.000000000 +0000 +++ foreign-0.8.69/MD5 2017-06-21 18:03:34.000000000 +0000 @@ -1,7 +1,7 @@ 23230f6ef6d4252d57567773a3f09154 *BUGS f87d40597e85fd95afb45eb64c651832 *COPYRIGHTS -c89afbfd611886ad4f78ef27ec1f49a6 *ChangeLog -a997bfc198a04adbac80f3bc9278aa0d *DESCRIPTION +700c3ecacf72b4ef40bb0daab8796039 *ChangeLog +b2c94eaad4d3993e6ada4bcf85fa760b *DESCRIPTION 2e82d3849af11b642299fc69ccef26f3 *GPL-2 ed8178a14789e97ce12174176eed1908 *NAMESPACE a6c68bd0f84690aab0887b99db7077e0 *R/R_systat.R @@ -13,15 +13,17 @@ 6bfc3bfc95408ad2c284cce192640b21 *R/read.dta.R 825a5bc34931831a333db909055b3f0c *R/read.epiinfo.R 1086e6cc7c1c3bbb16f5681d88801b7d *R/read.ssd.R -a10d200cc97ffbc9b6609c0b3107c0e1 *R/spss.R -312d28edc443cefac72b1b787773dd14 *R/writeForeignCode.R +cde6dd5828dd041c3eb82ac80ce98dd3 *R/spss.R +4f5adf432382c5a44d389065eac3e95b *R/writeForeignCode.R bccb3208a7215229b5e7c1db7432ad0b *R/writeForeignSAS.R 7424cbf0a5229f99040b9611365117f3 *R/xport.R 0337f989613243d0134c33eb5584953b *R/zzz.R efd25b6076bba3a05fcc2af925e92a80 *inst/COPYRIGHTS 03fec511a5a02a497bd959ee50ab290b *inst/files/HillRace.SYD 3335f0e1dd6812968776cc757a22ea78 *inst/files/Iris.syd +724515c420fe1c87636dab0a8753bbac *inst/files/electric.sav 739845e11f7e69826b04ca22a7d45568 *inst/files/sids.dbf +46e22eae53d3ab8456a97675f435cb61 *inst/files/testdata.sav be6355db2ecb8c19daae21fc7eba8c07 *inst/po/de/LC_MESSAGES/R-foreign.mo 5e8c336c1f52c498764f39119b4ee52e *inst/po/de/LC_MESSAGES/foreign.mo 94cb14919f8941bd6c3cffc894ce15c6 *inst/po/en@quot/LC_MESSAGES/R-foreign.mo @@ -34,18 +36,18 @@ 87a4728de4cc9fa5f10e1956bebf0436 *man/read.S.Rd e158337bb4c5753bee08025bb45c9901 *man/read.arff.Rd 655ab7f82d12e58ad15e1c1dc14ca3ac *man/read.dbf.Rd -7de8149ed19d445e4ebe589e99929803 *man/read.dta.Rd +6755c81830967f1190cd204dba98ed92 *man/read.dta.Rd d00ca890c4b2dcf919525ab9bbd6c2c0 *man/read.epiinfo.Rd 237a05c9be9b5783fc45f4b4fccecdfd *man/read.mtp.Rd db1bc6e2fb3330ae5d265b0a36d5f58a *man/read.octave.Rd -e986c2a68d601bf86d9c5a34d817efb0 *man/read.spss.Rd +78e10262567b1973de68ef01d9b3415c *man/read.spss.Rd 68b139470d8429706056879be85dbe90 *man/read.ssd.Rd 146b4ae1fc1dee5b33cd2f1958b7b72c *man/read.systat.Rd e4f1674e80a0d29e4f8bc60c0f27f1ea *man/read.xport.Rd 6477fdb9c3c8f2ae4c5333ac8e084b0c *man/write.arff.Rd -eacce6b42912cd4cced78dd15101620e *man/write.dbf.Rd +f12b27b4608118b61146fab29f4ba101 *man/write.dbf.Rd d9dcbade32a8c855029f066a90e6e70d *man/write.dta.Rd -eabbe51fb5b2fd3f9ed112c2d9c6b879 *man/write.foreign.Rd +3488df6faab757f05c8c4967d77b2100 *man/write.foreign.Rd c98b1eba8c57558175b7adc46bcbf5d8 *po/R-de.po 773f6c7ad97d4d85ae9ac3ecfae58914 *po/R-foreign.pot a5e9b1b774bcfaa334454130f652d1c8 *po/R-fr.po @@ -67,12 +69,12 @@ 4ab523323c1cdd3070b339621b08bb7e *src/foreign.h 76dc30dd66eb04eb31e109a571048d6c *src/format.c ba57918d9812b0751713e905c53c5d46 *src/format.h -6507e4dc9b4aec13c4a7c51ebe667abe *src/init.c +9f9207714c9f77a05ed271202aaafe1a *src/init.c 7d9abe6ee46aa33f6d397e0c4dd640ad *src/minitab.c 8dd1d1534ae3a97c0d5e677500bc2460 *src/pfm-read.c 0b155bb697ace4fd196dd0282a787752 *src/pfm.h 913d1eacdc04e0139ed1309715e61306 *src/pspp-format-def.h -d4bccbad890b09fd81576823bc52d1f5 *src/sfm-read.c +cc78330f3d59dba8fddbfba70df6e45f *src/sfm-read.c 57d2ead77446dcc448a46d6dda1a002a *src/sfm.h 415d9a842df63d8f5aa2f30dee9a3897 *src/sfmP.h 7170823cb63ff57d1656d137fcbd9a88 *src/shapefil.h @@ -95,14 +97,13 @@ c82c97b941d8c3dfbf780a18479c3c59 *tests/download.R 269d75f02a2d06d3a7e2b7a2bc621ac9 *tests/dumpdata 57ccf646d2c4ad366eb179b7e914312b *tests/electric.por -724515c420fe1c87636dab0a8753bbac *tests/electric.sav 859e5cbbd74fd94775c2c7f111ae2d71 *tests/ex1-51.mtp -9c6c8cffb5c06ed0db857e22b3bcf510 *tests/keep/codefile.sps +d9ebff4042010117916598a3d8b0745b *tests/keep/codefile.sps 85becb8dd1c037ccdd4072bcfbf5e6d9 *tests/keep/datafile.dat a175ed9be624fb4d92b3ca53bd88a9e5 *tests/minitab.R 57c6e64dd8bc3b41be2e7b6e698f46c2 *tests/minitab.Rout.save -11479e9961cac6c3c8b5b6f2834a04ae *tests/mval_bug.R -7498681a467a110896932e128a293808 *tests/mval_bug.Rout.save +6b10616d9a73a6b4c363d82bde67df4c *tests/mval_bug.R +28f601f25f4e1baca36e8e94bbf232b6 *tests/mval_bug.Rout.save fd75debed7f0899ba5020e2a7312658b *tests/mval_bug.sav d3c1fe7fba4ac4890fede6da3c62bbea *tests/mySobj e220c5057046bcc051a300ed2e593ae9 *tests/octave.R @@ -117,8 +118,8 @@ 4529f9257032e61890138da9cd4ae4b5 *tests/sample100.por 05a548c3dd3001dd1ae569bb7b487d13 *tests/sample100.sav 2345db6c922977bc34b94c4d50a703c9 *tests/sas.R -abe1e48f22097e9fc26cbca728a0d937 *tests/spss.R -27790f43a43bdffb2fb15cbb48909ecc *tests/spss.Rout.save +5356edbff8f515021b1e78ccfcc51dc7 *tests/spss.R +a40a0dffe167e85cfb6643f894c64407 *tests/spss.Rout.save 8f44f68889e702b80b267d274adf9cd6 *tests/spss_long.sav 09d18fba44288fd040d464b4706ccb55 *tests/stata.R 971fda7f61666c454d876e858a6955c8 *tests/stata.Rout.save diff -Nru foreign-0.8.67/R/spss.R foreign-0.8.69/R/spss.R --- foreign-0.8.67/R/spss.R 2015-02-15 16:29:32.000000000 +0000 +++ foreign-0.8.69/R/spss.R 2017-06-20 14:38:17.000000000 +0000 @@ -1,12 +1,11 @@ ### This file is part of the 'foreign' package for R. - ### -### Read SPSS system data files +### Read SPSS system data files ### ### Copyright 2000-2002 Saikat DebRoy -### Douglas M. Bates , -### Thomas Lumley -### Copyright 2007-2015 R Core Development Team +### Douglas M. Bates , +### Thomas Lumley +### Copyright 2007-2017 R Core Development Team ### Patched 2013-01-02 following PR#15073 by Peggy Overcashier ### This file is part of the `foreign' package for R and related languages. @@ -25,13 +24,18 @@ ### http://www.r-project.org/Licenses/ read.spss <- function(file, use.value.labels = TRUE, to.data.frame = FALSE, - max.value.labels = Inf, trim.factor.names = FALSE, + max.value.labels = Inf, trim.factor.names = FALSE, trim_values = TRUE, reencode = NA, - use.missings = to.data.frame) + use.missings = to.data.frame, sub = ".", + add.undeclared.levels = c("sort", "append", "no"), + duplicated.value.labels = c("append", "condense"), + duplicated.value.labels.infix = "_duplicated_", ...) { + add.undeclared.levels <- match.arg(add.undeclared.levels) + duplicated.value.labels <- match.arg(duplicated.value.labels) trim <- function(strings, trim=TRUE) - if (trim) sub(" +$","",strings) else strings + if (trim && is.character(strings)) sub(" +$", "", strings) else strings ## mappings taken from win-iconv knownCP <- c("UCS-2LE" = 1200, "UCS-2BE" = 1201, @@ -81,20 +85,25 @@ attr(rval, "codepage") <- NULL reencode <- FALSE } else cp <- paste("CP", codepage, sep="") - if(is.na(reencode)) - reencode <- l10n_info()[["UTF-8"]] && (codepage != 65001) + if(is.na(reencode)){ + l10ni <- l10n_info() + ## Do not reencode from UTF-8 in a UTF-8 locale and + ## not from latin1 in a latin1 locale + reencode <- (l10ni[["UTF-8"]] && (codepage != 65001)) || + (l10ni[["Latin-1"]] && (codepage != 28591)) + } if(reencode) { message(gettextf("re-encoding from %s", cp), domain = NA) - names(rval) <- iconv(names(rval), cp, "") + names(rval) <- iconv(names(rval), cp, "", sub=sub) vl <- attr(rval, "variable.labels") nm <- names(vl) - vl <- iconv(vl, cp, "") - names(vl) <- iconv(nm, cp, "") + vl <- iconv(vl, cp, "", sub=sub) + names(vl) <- iconv(nm, cp, "", sub=sub) attr(rval, "variable.labels") <- vl for(i in seq_along(rval)) { xi <- rval[[i]] - if(is.character(xi)) rval[[i]] <- iconv(xi, cp, "") + if(is.character(xi)) rval[[i]] <- iconv(xi, cp, "", sub=sub) } } } @@ -104,10 +113,10 @@ if(!is.null(miss)) { if(reencode) { nm <- names(miss) - names(miss) <- iconv(nm, cp, "") + names(miss) <- iconv(nm, cp, "", sub=sub) for(i in seq_along(miss)) if(is.character(miss[[i]]$value)) - miss[[i]]$value <- iconv(miss[[i]]$value, cp, "") + miss[[i]]$value <- iconv(miss[[i]]$value, cp, "", sub=sub) attr(rval, "missings") <- miss } if(use.missings) @@ -157,23 +166,67 @@ } } else use.missings <- FALSE - if(reencode) names(vl) <- iconv(names(vl), cp, "") + if(reencode) names(vl) <- iconv(names(vl), cp, "", sub=sub) has.vl <- which(!sapply(vl, is.null)) for(v in has.vl) { nm <- names(vl)[[v]] - nvalues <- length(na.omit(unique(rval[[nm]]))) - nlabels <- length(vl[[v]]) + vlv <- vl[[v]] + nlabels <- length(vlv) if(reencode && nlabels) { - nm2 <- names(vl[[v]]) - vl[[v]] <- iconv(vl[[v]], cp, "") - names(vl[[v]]) <- iconv(nm2, cp, "") + nm2 <- names(vlv) + vl[[v]] <- vlv <- iconv(vlv, cp, "", sub=sub) + names(vl[[v]]) <- names(vlv) <- iconv(nm2, cp, "", sub=sub) } - if (use.value.labels && - (!is.finite(max.value.labels) || nvalues <= max.value.labels) && - nlabels >= nvalues) { - rval[[nm]] <- factor(trim(rval[[nm]], trim_values), - levels = rev(trim(vl[[v]], trim_values)), - labels = rev(trim(names(vl[[v]]), trim.factor.names))) + + newlevels <- rev(trim(vlv, trim_values)) + newrval <- trim(rval[[nm]], trim_values) + + uniquevalues <- na.omit(unique(newrval)) + nvalues <- length(uniquevalues) + + ## We may have nlabels == nvalues but they do not always match, + ## e.g. in case 2 labels are duplicated, hence be careful: + if (use.value.labels && (add.undeclared.levels != "no" || all(uniquevalues %in% c(newlevels, ""))) && + (!is.finite(max.value.labels) || nvalues <= max.value.labels)) { + + newlabels <- rev(trim(names(vlv), trim.factor.names)) + if(add.undeclared.levels != "no" && !all(uniquevalues %in% c(newlevels, ""))){ + addlabels <- addlevels <- sort(uniquevalues[!(uniquevalues %in% c(newlevels, ""))]) + newlevels <- c(newlevels, addlevels) + newlabels <- c(newlabels, addlabels) + if(add.undeclared.levels == "sort"){ + o <- order(newlevels) + newlevels <- newlevels[o] + newlabels <- newlabels[o] + } + warning("Undeclared level(s) ", paste(addlevels, collapse = ", "), " added in variable: ", nm) + } + dupnewlabels <- duplicated(newlabels) + ## duplicated factor labels are no longer possible for R >= 3.4.0, + ## hence adding two ways around + ## - append: appends infix plus original level (that is unique) + ## - condense: removes additional levels with identical labels and + ## condenses to the first of all duplicated levels + if(any(dupnewlabels)) { + warning("Duplicated levels in factor ", nm, ": ", + paste(newlabels[dupnewlabels], collapse=", ")) + if(duplicated.value.labels == "append"){ + newlabels[dupnewlabels] <- + paste(newlabels[dupnewlabels], newlevels[dupnewlabels], + sep = duplicated.value.labels.infix) + } + if(duplicated.value.labels == "condense"){ + for(d in unique(newlabels[dupnewlabels])){ + dups <- newlabels %in% d + newrval[newrval %in% newlevels[dups]] <- newlevels[dups][1] + } + newlabels <- newlabels[!dupnewlabels] + newlevels <- newlevels[!dupnewlabels] + } + } + rval[[nm]] <- factor(newrval, + levels = newlevels, + labels = newlabels) } else attr(rval[[nm]], "value.labels") <- vl[[v]] } @@ -181,7 +234,7 @@ if (to.data.frame) { varlab <- attr(rval, "variable.labels") - rval <- as.data.frame(rval) + rval <- as.data.frame(rval, ...) attr(rval, "variable.labels") <- varlab if(codepage > 500) attr(rval, "codepage") <- codepage } diff -Nru foreign-0.8.67/R/writeForeignCode.R foreign-0.8.69/R/writeForeignCode.R --- foreign-0.8.67/R/writeForeignCode.R 2013-12-05 16:50:02.000000000 +0000 +++ foreign-0.8.69/R/writeForeignCode.R 2017-05-04 13:31:09.000000000 +0000 @@ -24,18 +24,26 @@ ## we want ASCII quotes, not UTF-8 quotes here adQuote <- function(x) paste("\"", x, "\"", sep = "") -writeForeignSPSS <- function(df, datafile, codefile, varnames = NULL) + + +## FIXME: +# - Missing values +# - Date/Time +# - character variables > 255 chars +# - wrapper to write .sav directly + +writeForeignSPSS <- function(df, datafile, codefile, varnames = NULL, maxchars = 32L) { ## FIXME: re-write this to hold a connection open dfn <- lapply(df, function(x) if (is.factor(x)) as.numeric(x) else x) write.table(dfn, file = datafile, row.names = FALSE, col.names = FALSE, - sep = ",", quote = FALSE, na = "",eol = ",\n") + sep = ",", quote = FALSE, na = "", eol = ",\n") varlabels <- names(df) if (is.null(varnames)) { - varnames <- abbreviate(names(df), 8L) - if (any(sapply(varnames, nchar) > 8L)) - stop("I cannot abbreviate the variable names to eight or fewer letters") + varnames <- abbreviate(names(df), maxchars) + if (any(sapply(varnames, nchar) > maxchars)) + stop("I cannot abbreviate the variable names to 'maxchars' or fewer chars") if (any(varnames != varlabels)) warning("some variable names were abbreviated") } @@ -43,26 +51,38 @@ varnames <- gsub("[^[:alnum:]_\\$@#]", "\\.", varnames) dl.varnames <- varnames - if (any(chv <- sapply(df,is.character))) { - lengths <- sapply(df[chv],function(v) max(nchar(v))) - if(any(lengths > 255L)) - stop("Cannot handle character variables longer than 255") + chv <- sapply(df, is.character) + fav <- sapply(df, is.factor) + if (any(chv)) { + lengths <- sapply(df[chv],function(v) max(c(nchar(v),8), na.rm=TRUE)) lengths <- paste0("(A", lengths, ")") - # corrected by PR#15583 - star <- ifelse(c(TRUE, diff(which(chv) > 1L))," *", " ") - dl.varnames[chv] <- paste(star, dl.varnames[chv], lengths) - } - + dl.varnames[chv] <- paste(dl.varnames[chv], lengths) + } + if (any(fav)) { + dl.varnames[fav] <- paste(dl.varnames[fav], "(F8.0)") # Factor-Format + } + if (any(chv) || any(fav)) { + ## actually the rule is: prepend a star if a variable with type/size declaration + ## follows on a variable without declaration; no star for first variable or variables + ## following other variables with declarations + star <- ifelse(c(FALSE, diff(chv | fav) == 1)[chv | fav], " *", " ") + dl.varnames[chv | fav] <- paste(star, dl.varnames[chv | fav]) + } + + cat("SET DECIMAL=DOT.\n\n", file = codefile) # required if SPSS runs in a locale with DECIMAL=comma cat("DATA LIST FILE=", adQuote(datafile), " free (\",\")\n", - file = codefile) - cat("/", dl.varnames, " .\n\n", file = codefile, append = TRUE) + file = codefile, append = TRUE) + cat('ENCODING="Locale"\n', file = codefile, append = TRUE) + + ## No line longer than 251 chars: + cat("/", paste(strwrap(paste(dl.varnames, collapse=" "), width=70), "\n"), " .\n\n", + file = codefile, append = TRUE) cat("VARIABLE LABELS\n", file = codefile, append = TRUE) cat(paste(varnames, adQuote(varlabels),"\n"), ".\n", file = codefile, append = TRUE) - factors <- sapply(df,is.factor) - if (any(factors)) { + if (any(fav)) { cat("\nVALUE LABELS\n", file = codefile, append = TRUE) - for(v in which(factors)){ + for(v in which(fav)){ cat("/\n", file = codefile, append = TRUE) cat(varnames[v]," \n", file = codefile, append = TRUE, sep = "") levs <- levels(df[[v]]) @@ -71,6 +91,19 @@ } cat(".\n", file = codefile, append = TRUE) } + + ord <- sapply(df, is.ordered) + if(any(ord)) + cat("VARIABLE LEVEL", + paste(strwrap(paste(varnames[ord], collapse = ", "), width=70), "\n"), + "(ordinal).\n", file = codefile, append = TRUE) + + num <- sapply(df, is.numeric) + if(any(num)) + cat("VARIABLE LEVEL", + paste(strwrap(paste(varnames[num], collapse = ", "), width=70), "\n"), + "(scale).\n", file = codefile, append = TRUE) + cat("\nEXECUTE.\n", file = codefile, append = TRUE) } diff -Nru foreign-0.8.67/src/init.c foreign-0.8.69/src/init.c --- foreign-0.8.67/src/init.c 2016-09-13 10:12:04.000000000 +0000 +++ foreign-0.8.69/src/init.c 2017-06-21 15:59:59.000000000 +0000 @@ -69,7 +69,5 @@ { R_registerRoutines(dll, CEntries, CallEntries, NULL, ExtEntries); R_useDynamicSymbols(dll, FALSE); -#if defined(R_VERSION) && R_VERSION >= R_Version(3, 0, 0) R_forceSymbols(dll, TRUE); -#endif } diff -Nru foreign-0.8.67/src/sfm-read.c foreign-0.8.69/src/sfm-read.c --- foreign-0.8.67/src/sfm-read.c 2016-09-13 10:12:04.000000000 +0000 +++ foreign-0.8.69/src/sfm-read.c 2017-06-21 15:59:59.000000000 +0000 @@ -1,7 +1,8 @@ /* PSPP - computes sample statistics. Copyright (C) 1997-9, 2000 Free Software Foundation, Inc. Written by Ben Pfaff . - Modified for R foreign library by Saikat DebRoy . + Modified for R foreign package by Saikat DebRoy + Patches by the R Core Team 2001-2017. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as @@ -403,24 +404,39 @@ switch (data.subtype) { - case 3: + + /* subtypes as specified by PSPP documentation at + https://www.gnu.org/software/pspp/pspp-dev/html_node/System-File-Format.html#System-File-Format + */ + + case 3: /* Machine integer information */ if (!read_machine_int32_info (h, data.size, data.count, &(inf->encoding))) goto lossage; break; - case 4: + case 4: /* Machine floating point information */ if (!read_machine_flt64_info (h, data.size, data.count)) goto lossage; break; - case 5: - case 6: - case 11: /* ?? Used by SPSS 8.0. */ + case 5: /* grouped variables */ skip = 1; break; - case 7: /* Multiple-response sets (later versions of SPSS). */ + case 6: /* some rarely used date information */ + skip = 1; + break; + + case 7: /* Multiple-response sets */ + skip = 1; + break; + + case 11: /*Variable Display Parameter Record */ + skip = 1; + break; + + case 12: /* UUID, rarely used */ skip = 1; break; @@ -430,14 +446,45 @@ goto lossage; break; - case 16: /* See http://www.nabble.com/problem-loading-SPSS-15.0-save-files-t2726500.html */ + case 14: /* Very Long String Record */ + warning(_("%s: Very long string record(s) found (record type 7, subtype %d), each will be imported in consecutive separate variables"), h->fn, data.subtype); skip = 1; break; - case 20: + case 16: /* Extended Number of Cases Record (64-bit integer to represent ncases rather than 32-bit in system file header) */ + skip = 1; + break; + + case 17: /* Data File Attributes Record */ + skip = 1; + break; + + case 18: /* Variable Attributes Records */ skip = 1; break; + case 19: /* bninary multiple-response sets */ + skip = 1; + break; + + case 20: /* another codepage information */ + skip = 1; + break; + + case 21: /* Long String Value Labels Record */ + warning(_("%s: Long string value labels record found (record type 7, subtype %d), but ignored"), h->fn, data.subtype); + skip = 1; + break; + + case 22: /* Long String Missing Values Record */ + warning(_("%s: Long string missing values record found (record type 7, subtype %d), but ignored"), h->fn, data.subtype); + skip = 1; + break; + + case 24: /* XML that describes how data in the file should be displayed on-screen */ + skip = 1; + break; + default: warning(_("%s: Unrecognized record type 7, subtype %d encountered in system file"), h->fn, data.subtype); skip = 1; @@ -909,16 +956,18 @@ /* FIXME: much of this is incorrect if the file is encoded in a MBCS */ /* Copy first character of variable name. */ + + /* it seems in a comparison on 1338 SPSS files, that this is always a false positive: if (!isalpha ((unsigned char) sv.name[0]) && sv.name[0] != '@' && sv.name[0] != '#') lose ((_("%s: position %d: Variable name begins with invalid character"), h->fn, i)); - if (islower ((unsigned char) sv.name[0])) + if (islower ((unsigned char) sv.name[0])) warning(_("%s: position %d: Variable name begins with lowercase letter %c"), - h->fn, i, sv.name[0]); + h->fn, i, sv.name[0]); */ if (sv.name[0] == '#') warning(_("%s: position %d: Variable name begins with octothorpe ('#'). Scratch variables should not appear in system files"), h->fn, i); - vv->name[0] = (char) toupper ((unsigned char) (sv.name[0])); + vv->name[0] = (char) (sv.name[0]); /* Copy remaining characters of variable name. */ for (j = 1; j < 8; j++) @@ -929,9 +978,10 @@ break; else if (islower (c)) { - warning(_("%s: position %d: Variable name character %d is lowercase letter %c"), - h->fn, i, j + 1, sv.name[j]); - vv->name[j] = (char) toupper ((unsigned char) (c)); + /* it seems in a comparison on 1338 SPSS files, that this is always a false positive: + warning(_("%s: position %d: Variable name character %d is lowercase letter %c"), + h->fn, i, j + 1, sv.name[j]);*/ + vv->name[j] = (char) (c); } else if (isalnum (c) || c == '.' || c == '@' || c == '#' || c == '$' || c == '_' || c > 127) @@ -1048,9 +1098,15 @@ else vv->miss_type = MISSING_NONE; - if (!parse_format_spec (h, sv.print, &vv->print, vv) - || !parse_format_spec (h, sv.write, &vv->write, vv)) + if (!parse_format_spec (h, sv.print, &vv->print, vv)) goto lossage; +/* We do not need this part in the if() condition: + || !parse_format_spec (h, sv.write, &vv->write, vv)) + as this produces some uncertainty about the format type given + https://www.gnu.org/software/pspp/pspp-dev/html_node/Variable-Record.html#Variable-Record + tells us on June 9, 2017: + "A few system files have been observed in the wild with invalid write fields, in particular with value 0. Readers should probably treat invalid print or write fields as some default format. " +*/ } /* Some consistency checks. */ Binary files /tmp/tmpUk6gBr/2u58pHhyRV/foreign-0.8.67/tests/electric.sav and /tmp/tmpUk6gBr/03HMaNbG2m/foreign-0.8.69/tests/electric.sav differ diff -Nru foreign-0.8.67/tests/keep/codefile.sps foreign-0.8.69/tests/keep/codefile.sps --- foreign-0.8.67/tests/keep/codefile.sps 2013-12-05 16:50:02.000000000 +0000 +++ foreign-0.8.69/tests/keep/codefile.sps 2017-06-20 15:15:47.000000000 +0000 @@ -1,10 +1,16 @@ -DATA LIST FILE= "datafile.dat" free (",") -/ X1 X2 * X3 (A5) . - -VARIABLE LABELS -X1 "X1" - X2 "X2" - X3 "X3" - . - -EXECUTE. +SET DECIMAL=DOT. + +DATA LIST FILE= "datafile.dat" free (",") +ENCODING="Locale" +/ X1 X2 * X3 (A8) + . + +VARIABLE LABELS +X1 "X1" + X2 "X2" + X3 "X3" + . +VARIABLE LEVEL X1, X2 + (scale). + +EXECUTE. diff -Nru foreign-0.8.67/tests/mval_bug.R foreign-0.8.69/tests/mval_bug.R --- foreign-0.8.67/tests/mval_bug.R 2013-01-04 14:03:05.000000000 +0000 +++ foreign-0.8.69/tests/mval_bug.R 2017-06-20 15:01:06.000000000 +0000 @@ -1,7 +1,7 @@ library(foreign) -mydata <- read.spss("mval_bug.sav", use.value.labels = TRUE, - to.data.frame = TRUE, use.missings = TRUE) +mydata <- suppressMessages(read.spss("mval_bug.sav", use.value.labels = TRUE, + to.data.frame = TRUE, use.missings = TRUE)) levels(mydata$Q1_MISSING_NONE) table(mydata$Q1_MISSING_NONE) diff -Nru foreign-0.8.67/tests/mval_bug.Rout.save foreign-0.8.69/tests/mval_bug.Rout.save --- foreign-0.8.67/tests/mval_bug.Rout.save 2013-01-04 14:03:05.000000000 +0000 +++ foreign-0.8.69/tests/mval_bug.Rout.save 2017-06-20 15:19:35.000000000 +0000 @@ -1,143 +1,138 @@ - -R Under development (unstable) (2013-01-01 r61505) -- "Unsuffered Consequences" -Copyright (C) 2013 The R Foundation for Statistical Computing -ISBN 3-900051-07-0 -Platform: x86_64-apple-darwin11.4.2/x86_64 (64-bit) - -R is free software and comes with ABSOLUTELY NO WARRANTY. -You are welcome to redistribute it under certain conditions. -Type 'license()' or 'licence()' for distribution details. - -R is a collaborative project with many contributors. -Type 'contributors()' for more information and -'citation()' on how to cite R or R packages in publications. - -Type 'demo()' for some demos, 'help()' for on-line help, or -'help.start()' for an HTML browser interface to help. -Type 'q()' to quit R. - -> library(foreign) -> -> mydata <- read.spss("mval_bug.sav", use.value.labels = TRUE, -+ to.data.frame = TRUE, use.missings = TRUE) -re-encoding from latin1 -Warning message: -In read.spss("mval_bug.sav", use.value.labels = TRUE, to.data.frame = TRUE, : - mval_bug.sav: Unrecognized record type 7, subtype 18 encountered in system file -> -> levels(mydata$Q1_MISSING_NONE) -[1] "(-3) Missing" "(-2) Don't know" -[3] "(-1) Refused" "(1) Approve STRONGLY" -[5] "(2) Approve SOMEWHAT" "(3) Disapprove SOMEWHAT" -[7] "(4) Disapprove STRONGLY" "(99) Coding error" -> table(mydata$Q1_MISSING_NONE) - - (-3) Missing (-2) Don't know (-1) Refused - 17 8 5 - (1) Approve STRONGLY (2) Approve SOMEWHAT (3) Disapprove SOMEWHAT - 142 104 71 -(4) Disapprove STRONGLY (99) Coding error - 250 3 -> -> levels(mydata$Q1_MISSING_1) -[1] "(-3) Missing" "(-2) Don't know" -[3] "(1) Approve STRONGLY" "(2) Approve SOMEWHAT" -[5] "(3) Disapprove SOMEWHAT" "(4) Disapprove STRONGLY" -[7] "(99) Coding error" -> table(mydata$Q1_MISSING_1) - - (-3) Missing (-2) Don't know (1) Approve STRONGLY - 17 8 142 - (2) Approve SOMEWHAT (3) Disapprove SOMEWHAT (4) Disapprove STRONGLY - 104 71 250 - (99) Coding error - 3 -> -> levels(mydata$Q1_MISSING_2) -[1] "(-3) Missing" "(1) Approve STRONGLY" -[3] "(2) Approve SOMEWHAT" "(3) Disapprove SOMEWHAT" -[5] "(4) Disapprove STRONGLY" "(99) Coding error" -> table(mydata$Q1_MISSING_2) - - (-3) Missing (1) Approve STRONGLY (2) Approve SOMEWHAT - 17 142 104 -(3) Disapprove SOMEWHAT (4) Disapprove STRONGLY (99) Coding error - 71 250 3 -> -> levels(mydata$Q1_MISSING_3) -[1] "(1) Approve STRONGLY" "(2) Approve SOMEWHAT" -[3] "(3) Disapprove SOMEWHAT" "(4) Disapprove STRONGLY" -[5] "(99) Coding error" -> table(mydata$Q1_MISSING_3) - - (1) Approve STRONGLY (2) Approve SOMEWHAT (3) Disapprove SOMEWHAT - 142 104 71 -(4) Disapprove STRONGLY (99) Coding error - 250 3 -> -> levels(mydata$Q1_MISSING_RANGE) -[1] "(1) Approve STRONGLY" "(2) Approve SOMEWHAT" -[3] "(3) Disapprove SOMEWHAT" "(4) Disapprove STRONGLY" -[5] "(99) Coding error" -> table(mydata$Q1_MISSING_RANGE) - - (1) Approve STRONGLY (2) Approve SOMEWHAT (3) Disapprove SOMEWHAT - 142 104 71 -(4) Disapprove STRONGLY (99) Coding error - 250 3 -> -> levels(mydata$Q1_MISSING_LOW) -[1] "(1) Approve STRONGLY" "(2) Approve SOMEWHAT" -[3] "(3) Disapprove SOMEWHAT" "(4) Disapprove STRONGLY" -[5] "(99) Coding error" -> table(mydata$Q1_MISSING_LOW) - - (1) Approve STRONGLY (2) Approve SOMEWHAT (3) Disapprove SOMEWHAT - 142 104 71 -(4) Disapprove STRONGLY (99) Coding error - 250 3 -> -> levels(mydata$Q1_MISSING_HIGH) -[1] "(-1) Coding error" "(1) Approve STRONGLY" -[3] "(2) Approve SOMEWHAT" "(3) Disapprove SOMEWHAT" -[5] "(4) Disapprove STRONGLY" -> table(mydata$Q1_MISSING_HIGH) - - (-1) Coding error (1) Approve STRONGLY (2) Approve SOMEWHAT - 3 142 104 -(3) Disapprove SOMEWHAT (4) Disapprove STRONGLY - 71 250 -> -> levels(mydata$Q1_MISSING_RANGE_1) -[1] "(1) Approve STRONGLY" "(2) Approve SOMEWHAT" -[3] "(3) Disapprove SOMEWHAT" "(4) Disapprove STRONGLY" -> table(mydata$Q1_MISSING_RANGE_1) - - (1) Approve STRONGLY (2) Approve SOMEWHAT (3) Disapprove SOMEWHAT - 142 104 71 -(4) Disapprove STRONGLY - 250 -> -> levels(mydata$Q1_MISSING_LOW_1) -[1] "(1) Approve STRONGLY" "(2) Approve SOMEWHAT" -[3] "(3) Disapprove SOMEWHAT" "(4) Disapprove STRONGLY" -> table(mydata$Q1_MISSING_LOW_1) - - (1) Approve STRONGLY (2) Approve SOMEWHAT (3) Disapprove SOMEWHAT - 142 104 71 -(4) Disapprove STRONGLY - 250 -> -> levels(mydata$Q1_MISSING_HIGH_1) -[1] "(1) Approve STRONGLY" "(2) Approve SOMEWHAT" -[3] "(3) Disapprove SOMEWHAT" "(4) Disapprove STRONGLY" -> table(mydata$Q1_MISSING_HIGH_1) - - (1) Approve STRONGLY (2) Approve SOMEWHAT (3) Disapprove SOMEWHAT - 142 104 71 -(4) Disapprove STRONGLY - 250 -> -> proc.time() - user system elapsed - 0.284 0.029 0.300 + +R Under development (unstable) (2017-06-20 r72811) -- "Unsuffered Consequences" +Copyright (C) 2017 The R Foundation for Statistical Computing +Platform: x86_64-w64-mingw32/x64 (64-bit) + +R is free software and comes with ABSOLUTELY NO WARRANTY. +You are welcome to redistribute it under certain conditions. +Type 'license()' or 'licence()' for distribution details. + +R is a collaborative project with many contributors. +Type 'contributors()' for more information and +'citation()' on how to cite R or R packages in publications. + +Type 'demo()' for some demos, 'help()' for on-line help, or +'help.start()' for an HTML browser interface to help. +Type 'q()' to quit R. + +> library(foreign) +> +> mydata <- suppressMessages(read.spss("mval_bug.sav", use.value.labels = TRUE, ++ to.data.frame = TRUE, use.missings = TRUE)) +> +> levels(mydata$Q1_MISSING_NONE) +[1] "(-3) Missing" "(-2) Don't know" +[3] "(-1) Refused" "(1) Approve STRONGLY" +[5] "(2) Approve SOMEWHAT" "(3) Disapprove SOMEWHAT" +[7] "(4) Disapprove STRONGLY" "(99) Coding error" +> table(mydata$Q1_MISSING_NONE) + + (-3) Missing (-2) Don't know (-1) Refused + 17 8 5 + (1) Approve STRONGLY (2) Approve SOMEWHAT (3) Disapprove SOMEWHAT + 142 104 71 +(4) Disapprove STRONGLY (99) Coding error + 250 3 +> +> levels(mydata$Q1_MISSING_1) +[1] "(-3) Missing" "(-2) Don't know" +[3] "(1) Approve STRONGLY" "(2) Approve SOMEWHAT" +[5] "(3) Disapprove SOMEWHAT" "(4) Disapprove STRONGLY" +[7] "(99) Coding error" +> table(mydata$Q1_MISSING_1) + + (-3) Missing (-2) Don't know (1) Approve STRONGLY + 17 8 142 + (2) Approve SOMEWHAT (3) Disapprove SOMEWHAT (4) Disapprove STRONGLY + 104 71 250 + (99) Coding error + 3 +> +> levels(mydata$Q1_MISSING_2) +[1] "(-3) Missing" "(1) Approve STRONGLY" +[3] "(2) Approve SOMEWHAT" "(3) Disapprove SOMEWHAT" +[5] "(4) Disapprove STRONGLY" "(99) Coding error" +> table(mydata$Q1_MISSING_2) + + (-3) Missing (1) Approve STRONGLY (2) Approve SOMEWHAT + 17 142 104 +(3) Disapprove SOMEWHAT (4) Disapprove STRONGLY (99) Coding error + 71 250 3 +> +> levels(mydata$Q1_MISSING_3) +[1] "(1) Approve STRONGLY" "(2) Approve SOMEWHAT" +[3] "(3) Disapprove SOMEWHAT" "(4) Disapprove STRONGLY" +[5] "(99) Coding error" +> table(mydata$Q1_MISSING_3) + + (1) Approve STRONGLY (2) Approve SOMEWHAT (3) Disapprove SOMEWHAT + 142 104 71 +(4) Disapprove STRONGLY (99) Coding error + 250 3 +> +> levels(mydata$Q1_MISSING_RANGE) +[1] "(1) Approve STRONGLY" "(2) Approve SOMEWHAT" +[3] "(3) Disapprove SOMEWHAT" "(4) Disapprove STRONGLY" +[5] "(99) Coding error" +> table(mydata$Q1_MISSING_RANGE) + + (1) Approve STRONGLY (2) Approve SOMEWHAT (3) Disapprove SOMEWHAT + 142 104 71 +(4) Disapprove STRONGLY (99) Coding error + 250 3 +> +> levels(mydata$Q1_MISSING_LOW) +[1] "(1) Approve STRONGLY" "(2) Approve SOMEWHAT" +[3] "(3) Disapprove SOMEWHAT" "(4) Disapprove STRONGLY" +[5] "(99) Coding error" +> table(mydata$Q1_MISSING_LOW) + + (1) Approve STRONGLY (2) Approve SOMEWHAT (3) Disapprove SOMEWHAT + 142 104 71 +(4) Disapprove STRONGLY (99) Coding error + 250 3 +> +> levels(mydata$Q1_MISSING_HIGH) +[1] "(-1) Coding error" "(1) Approve STRONGLY" +[3] "(2) Approve SOMEWHAT" "(3) Disapprove SOMEWHAT" +[5] "(4) Disapprove STRONGLY" +> table(mydata$Q1_MISSING_HIGH) + + (-1) Coding error (1) Approve STRONGLY (2) Approve SOMEWHAT + 3 142 104 +(3) Disapprove SOMEWHAT (4) Disapprove STRONGLY + 71 250 +> +> levels(mydata$Q1_MISSING_RANGE_1) +[1] "(1) Approve STRONGLY" "(2) Approve SOMEWHAT" +[3] "(3) Disapprove SOMEWHAT" "(4) Disapprove STRONGLY" +> table(mydata$Q1_MISSING_RANGE_1) + + (1) Approve STRONGLY (2) Approve SOMEWHAT (3) Disapprove SOMEWHAT + 142 104 71 +(4) Disapprove STRONGLY + 250 +> +> levels(mydata$Q1_MISSING_LOW_1) +[1] "(1) Approve STRONGLY" "(2) Approve SOMEWHAT" +[3] "(3) Disapprove SOMEWHAT" "(4) Disapprove STRONGLY" +> table(mydata$Q1_MISSING_LOW_1) + + (1) Approve STRONGLY (2) Approve SOMEWHAT (3) Disapprove SOMEWHAT + 142 104 71 +(4) Disapprove STRONGLY + 250 +> +> levels(mydata$Q1_MISSING_HIGH_1) +[1] "(1) Approve STRONGLY" "(2) Approve SOMEWHAT" +[3] "(3) Disapprove SOMEWHAT" "(4) Disapprove STRONGLY" +> table(mydata$Q1_MISSING_HIGH_1) + + (1) Approve STRONGLY (2) Approve SOMEWHAT (3) Disapprove SOMEWHAT + 142 104 71 +(4) Disapprove STRONGLY + 250 +> +> proc.time() + user system elapsed + 0.29 0.03 0.31 diff -Nru foreign-0.8.67/tests/spss.R foreign-0.8.69/tests/spss.R --- foreign-0.8.67/tests/spss.R 2014-01-26 11:57:40.000000000 +0000 +++ foreign-0.8.69/tests/spss.R 2017-06-21 11:53:28.000000000 +0000 @@ -25,20 +25,20 @@ str(pbc.) # has variable.labels stopifnot(all.equal(d.pbc, data.frame(pbc.), tolerance = 1e-15)) -electric.s <- read.spss("electric.sav",TRUE,TRUE) +electric.s <- read.spss(system.file("files", "electric.sav", package = "foreign"), TRUE, TRUE) electric.p <- read.spss("electric.por",TRUE,TRUE) -electric.s4 <- read.spss("electric.sav",TRUE,TRUE,max.value.labels = 4) +electric.s4 <- read.spss(system.file("files", "electric.sav", package = "foreign"), TRUE, TRUE, max.value.labels = 4) summary(electric.s) ii <- c(2,10) vl <- list(FIRSTCHD = c("OTHER CHD"= 6, "FATAL MI"= 5, "NONFATALMI"= 3, - "SUDDEN DEATH" = 2, "NO CHD" = 1), - DAYOFWK = c(SATURDAY=7, FRIDAY=6, THURSDAY=5, - WEDNSDAY=4, TUESDAY=3, MONDAY=2, SUNDAY=1)) -stopifnot(identical(electric.s, electric.p), - identical(electric.s[-ii], electric.s4[-ii]), - identical(vl, lapply(electric.s4[ii], attr, "value.labels")), - identical(lapply(vl, names), - lapply(electric.s[ii], function(.) rev(levels(.))))) + "SUDDEN DEATH" = 2, "NO CHD" = 1), + DAYOFWK = c(SATURDAY=7, FRIDAY=6, THURSDAY=5, + WEDNSDAY=4, TUESDAY=3, MONDAY=2, SUNDAY=1)) +stopifnot(identical(electric.s, electric.p), + identical(electric.s[-ii], electric.s4[-ii]), + identical(vl, lapply(electric.s4[ii], attr, "value.labels")), + identical(lapply(vl, names), + lapply(electric.s[ii], function(.) rev(levels(.))))) ## after "long label patch": @@ -49,4 +49,57 @@ nnms <- nms <- names(ldat) names(nnms) <- nms stopifnot(identical(nms, c("variable1", "variable2")), - identical(nnms, attr(ldat, "variable.labels"))) + identical(nnms, attr(ldat, "variable.labels"))) + + +## some new arkward testcases for problems found in foreign <= 0.8-68 and duplicated value labels in general: + +## Expect lots of warnings as value labels (corresponding to R factor labels) are uncomplete, +## and an unsupported long string variable is present in the data + +setwd(system.file("files", package = "foreign")) +sav <- "testdata.sav" + +x.nodat <- read.spss(file=sav, to.data.frame = FALSE, reencode="UTF-8") +str(x.nodat) + +x.sort <- read.spss(file=sav, to.data.frame = TRUE, reencode="UTF-8") +str(x.sort) +x.append <- read.spss(file=sav, to.data.frame = TRUE, + add.undeclared.levels = "append", reencode="UTF-8") +x.no <- read.spss(file=sav, to.data.frame = TRUE, + add.undeclared.levels = "no", reencode="UTF-8") + +levels(x.sort$factor_n_undeclared) +levels(x.append$factor_n_undeclared) +str(x.no$factor_n_undeclared) + + +### Examples for duplicated.value.labels: +## duplicated.value.labels = "append" (default) +x.append <- read.spss(file=sav, to.data.frame=TRUE, reencode="UTF-8") +## duplicated.value.labels = "condense" +x.condense <- read.spss(file=sav, to.data.frame=TRUE, + duplicated.value.labels = "condense", reencode="UTF-8") + +levels(x.append$factor_n_duplicated) +levels(x.condense$factor_n_duplicated) + +as.numeric(x.append$factor_n_duplicated) +as.numeric(x.condense$factor_n_duplicated) + +### ToDo: +## Long Strings (>255 chars) are imported in consecutive separate variables +## (see warning about subtype 14) +## we should get that right in the import function in future versions +x <- read.spss(file=sav, to.data.frame=TRUE, stringsAsFactors=FALSE, reencode="UTF-8") + +cat.long.string <- function(x, w=70) cat(paste(strwrap(x, width=w), "\n")) + +## first part: x$string_500: +cat.long.string(x$string_500) +## second part: x$STRIN0: +cat.long.string(x$STRIN0) +## complete long string: +long.string <- apply(x[,c("string_500", "STRIN0")], 1, paste, collapse="") +cat.long.string(long.string) diff -Nru foreign-0.8.67/tests/spss.Rout.save foreign-0.8.69/tests/spss.Rout.save --- foreign-0.8.67/tests/spss.Rout.save 2014-01-26 11:57:40.000000000 +0000 +++ foreign-0.8.69/tests/spss.Rout.save 2017-06-21 11:56:33.000000000 +0000 @@ -1,327 +1,655 @@ - -R Under development (unstable) (2012-02-09 r58309) -Copyright (C) 2012 The R Foundation for Statistical Computing -ISBN 3-900051-07-0 -Platform: i386-apple-darwin9.8.0/i386 (32-bit) - -R is free software and comes with ABSOLUTELY NO WARRANTY. -You are welcome to redistribute it under certain conditions. -Type 'license()' or 'licence()' for distribution details. - -R is a collaborative project with many contributors. -Type 'contributors()' for more information and -'citation()' on how to cite R or R packages in publications. - -Type 'demo()' for some demos, 'help()' for on-line help, or -'help.start()' for an HTML browser interface to help. -Type 'q()' to quit R. - -> library(foreign) -> -> sample100 <- read.spss("sample100.sav",FALSE) -> summary(sample100) - Length Class Mode -YEAR 100 -none- numeric -DISTRICT 100 -none- numeric -CAMPUS 100 -none- numeric -DNAME 100 -none- character -CNAME 100 -none- character -SEX 100 -none- character -DISADVG 100 -none- character -ETHNICTY 100 -none- character -STUID 100 -none- character -TLIMTH 100 -none- numeric -GRADE 100 -none- numeric -> str(sample100) -List of 11 - $ YEAR : num [1:100] 99 94 94 95 96 97 98 99 94 95 ... - $ DISTRICT: num [1:100] 57914 57914 57914 57914 57914 ... - $ CAMPUS : num [1:100] 57914045 57914106 57914110 57914123 57914117 ... - $ DNAME : chr [1:100] "MESQUITE ISD " "MESQUITE ISD " "MESQUITE ISD " "MESQUITE ISD " ... - $ CNAME : chr [1:100] "A C NEW MIDDLE " "MCWHORTER EL " "RUTHERFORD EL " "JOEY M PIRRUNG " ... - $ SEX : chr [1:100] "F" "F" " " "F" ... - $ DISADVG : chr [1:100] "NO " "NO " " " "NO " ... - $ ETHNICTY: chr [1:100] "WHITE " "WHITE " " " "HISPANIC" ... - $ STUID : chr [1:100] "00614371S" "00614372S" "00614373S" "00614373S" ... - $ TLIMTH : num [1:100] 90 86 67 77 77 79 86 87 89 85 ... - $ GRADE : num [1:100] 8 3 3 4 5 6 7 8 3 4 ... - - attr(*, "label.table")=List of 11 - ..$ YEAR : NULL - ..$ DISTRICT: NULL - ..$ CAMPUS : NULL - ..$ DNAME : NULL - ..$ CNAME : NULL - ..$ SEX : NULL - ..$ DISADVG : NULL - ..$ ETHNICTY: NULL - ..$ STUID : NULL - ..$ TLIMTH : NULL - ..$ GRADE : NULL - - attr(*, "variable.labels")= Named chr [1:11] "YEAR OF ADMINISTRATION" "COUNTY DISTRICT NUMBER" "COUNTY DISTRICT CAMPUS NUMBER" "DISTRICT NAME" ... - ..- attr(*, "names")= chr [1:11] "YEAR" "DISTRICT" "CAMPUS" "DNAME" ... -> d.sample100 <- data.frame(sample100) -> summary(d.sample100) - YEAR DISTRICT CAMPUS DNAME - Min. : 94.0 Min. : 57905 Min. : 57905126 DALLAS ISD : 1 - 1st Qu.: 95.0 1st Qu.: 57914 1st Qu.: 57914046 HARMONY ISD : 1 - Median : 96.0 Median : 57914 Median : 57914112 MESQUITE ISD :96 - Mean : 115.4 Mean : 59644 Mean : 59644015 SUNNYVALE ISD : 2 - 3rd Qu.: 98.0 3rd Qu.: 57914 3rd Qu.: 57914125 - Max. :2000.0 Max. :230905 Max. :230905101 - - CNAME SEX DISADVG ETHNICTY STUID - J C AUSTIN EL :23 : 4 : 4 : 4 00614373S: 6 - R S KIMBROUGH M:12 F:62 NO :90 HISPANIC: 3 00614378S: 6 - WILKINSON MIDDL: 9 M:34 YES: 6 OTHER : 2 00614379S: 6 - VERNON PRICE EL: 7 WHITE :91 00614389S: 6 - TISINGER EL : 6 00614397S: 6 - THOMPSON EL : 5 00614403S: 6 - (Other) :38 (Other) :64 - TLIMTH GRADE - Min. :54.00 Min. :3.00 - 1st Qu.:74.00 1st Qu.:4.00 - Median :84.00 Median :5.00 - Mean :80.16 Mean :5.37 - 3rd Qu.:87.00 3rd Qu.:7.00 - Max. :93.00 Max. :8.00 - -> s100 <- sample100 -> sample100 <- read.spss("sample100.por",FALSE) -> stopifnot(identical(s100, sample100)) # no need for further summary() etc -> -> pbc <- read.spss("pbc.sav",FALSE) -> summary(pbc) - Length Class Mode -AGE 418 -none- numeric -ALB 418 -none- numeric -ALKPHOS 418 -none- numeric -ASCITES 418 -none- numeric -BILI 418 -none- numeric -CHOL 418 -none- numeric -EDEMA 418 -none- numeric -EDTRT 418 -none- numeric -HEPMEG 418 -none- numeric -TIME 418 -none- numeric -PLATELET 418 -none- numeric -PROTIME 418 -none- numeric -SEX 418 -none- numeric -SGOT 418 -none- numeric -SPIDERS 418 -none- numeric -STAGE 418 -none- numeric -STATUS 418 -none- numeric -TRT 418 -none- numeric -TRIG 418 -none- numeric -COPPER 418 -none- numeric -> str(pbc) -List of 20 - $ AGE : num [1:418] 58.8 56.4 70.1 54.7 38.1 ... - $ ALB : num [1:418] 2.6 4.14 3.48 2.54 3.53 3.98 4.09 4 3.08 2.74 ... - $ ALKPHOS : num [1:418] 1718 7395 516 6122 671 ... - $ ASCITES : num [1:418] 1 0 0 0 0 0 0 0 0 1 ... - $ BILI : num [1:418] 14.5 1.1 1.4 1.8 3.4 0.8 1 0.3 3.2 12.6 ... - $ CHOL : num [1:418] 261 302 176 244 279 248 322 280 562 200 ... - $ EDEMA : num [1:418] 1 0 1 1 0 0 0 0 0 1 ... - $ EDTRT : num [1:418] 1 0 0.5 0.5 0 0 0 0 0 1 ... - $ HEPMEG : num [1:418] 1 1 0 1 1 1 1 0 0 0 ... - $ TIME : num [1:418] 400 4500 1012 1925 1504 ... - $ PLATELET: num [1:418] 190 221 151 183 136 -9 204 373 251 302 ... - $ PROTIME : num [1:418] 12.2 10.6 12 10.3 10.9 11 9.7 11 11 11.5 ... - $ SEX : num [1:418] 1 1 0 1 1 1 1 1 1 1 ... - $ SGOT : num [1:418] 137.9 113.5 96.1 60.6 113.2 ... - $ SPIDERS : num [1:418] 1 1 0 1 1 0 0 0 1 1 ... - $ STAGE : num [1:418] 4 3 4 4 3 3 3 3 2 4 ... - $ STATUS : num [1:418] 1 0 1 1 0 1 0 1 1 1 ... - $ TRT : num [1:418] 1 1 1 1 2 2 2 2 1 2 ... - $ TRIG : num [1:418] 172 88 55 92 72 63 213 189 88 143 ... - $ COPPER : num [1:418] 156 54 210 64 143 50 52 52 79 140 ... - - attr(*, "label.table")=List of 20 - ..$ AGE : NULL - ..$ ALB : NULL - ..$ ALKPHOS : NULL - ..$ ASCITES : NULL - ..$ BILI : NULL - ..$ CHOL : NULL - ..$ EDEMA : NULL - ..$ EDTRT : NULL - ..$ HEPMEG : NULL - ..$ TIME : NULL - ..$ PLATELET: NULL - ..$ PROTIME : NULL - ..$ SEX : NULL - ..$ SGOT : NULL - ..$ SPIDERS : NULL - ..$ STAGE : NULL - ..$ STATUS : NULL - ..$ TRT : NULL - ..$ TRIG : NULL - ..$ COPPER : NULL -> d.pbc <- data.frame(pbc) -> summary(d.pbc) - AGE ALB ALKPHOS ASCITES - Min. :26.28 Min. :1.960 Min. : -9 Min. :-9.000 - 1st Qu.:42.83 1st Qu.:3.243 1st Qu.: -9 1st Qu.:-9.000 - Median :51.00 Median :3.530 Median : 1009 Median : 0.000 - Mean :50.74 Mean :3.497 Mean : 1478 Mean :-2.225 - 3rd Qu.:58.24 3rd Qu.:3.770 3rd Qu.: 1708 3rd Qu.: 0.000 - Max. :78.44 Max. :4.640 Max. :13862 Max. : 1.000 - BILI CHOL EDEMA EDTRT - Min. : 0.300 Min. : -9.0 Min. :0.0000 Min. :0.0000 - 1st Qu.: 0.800 1st Qu.: -9.0 1st Qu.:0.0000 1st Qu.:0.0000 - Median : 1.400 Median : 252.5 Median :0.0000 Median :0.0000 - Mean : 3.221 Mean : 248.2 Mean :0.1196 Mean :0.1005 - 3rd Qu.: 3.400 3rd Qu.: 347.8 3rd Qu.:0.0000 3rd Qu.:0.0000 - Max. :28.000 Max. :1775.0 Max. :1.0000 Max. :1.0000 - HEPMEG TIME PLATELET PROTIME SEX - Min. :-9.0 Min. : 41 Min. : -9.0 Min. : 9.00 Min. :-9.000 - 1st Qu.:-9.0 1st Qu.:1093 1st Qu.:181.0 1st Qu.:10.00 1st Qu.:-9.000 - Median : 0.0 Median :1730 Median :248.0 Median :10.60 Median : 1.000 - Mean :-1.9 Mean :1918 Mean :250.0 Mean :10.73 Mean :-1.622 - 3rd Qu.: 1.0 3rd Qu.:2614 3rd Qu.:315.5 3rd Qu.:11.10 3rd Qu.: 1.000 - Max. : 1.0 Max. :4795 Max. :721.0 Max. :18.00 Max. : 1.000 - SGOT SPIDERS STAGE STATUS - Min. : -9.00 Min. :-9.000 Min. :-9.00000 Min. :0.0000 - 1st Qu.: -9.00 1st Qu.:-9.000 1st Qu.:-9.00000 1st Qu.:0.0000 - Median : 90.45 Median : 0.000 Median : 3.00000 Median :0.0000 - Mean : 89.20 Mean :-2.067 Mean :-0.01914 Mean :0.3852 - 3rd Qu.:135.75 3rd Qu.: 0.000 3rd Qu.: 4.00000 3rd Qu.:1.0000 - Max. :457.25 Max. : 1.000 Max. : 4.00000 Max. :1.0000 - TRT TRIG COPPER - Min. :-9.000 Min. : -9.0 Min. : -9.00 - 1st Qu.:-9.000 1st Qu.: -9.0 1st Qu.: -9.00 - Median : 1.000 Median : 85.0 Median : 50.50 - Mean :-1.167 Mean : 81.2 Mean : 70.09 - 3rd Qu.: 2.000 3rd Qu.:127.8 3rd Qu.:100.75 - Max. : 2.000 Max. :598.0 Max. :588.00 -> pbco <- read.spss("pbcold.sav",FALSE) -> stopifnot(identical(pbc, pbco)) -> ## summary(pbco) -> ## str(pbco) -> ## d.pbco <- data.frame(pbco) -> ## summary(d.pbco) -> pbc. <- read.spss("pbc.por",FALSE) -> summary(pbc.) - Length Class Mode -AGE 418 -none- numeric -ALB 418 -none- numeric -ALKPHOS 418 -none- numeric -ASCITES 418 -none- numeric -BILI 418 -none- numeric -CHOL 418 -none- numeric -EDEMA 418 -none- numeric -EDTRT 418 -none- numeric -HEPMEG 418 -none- numeric -TIME 418 -none- numeric -PLATELET 418 -none- numeric -PROTIME 418 -none- numeric -SEX 418 -none- numeric -SGOT 418 -none- numeric -SPIDERS 418 -none- numeric -STAGE 418 -none- numeric -STATUS 418 -none- numeric -TRT 418 -none- numeric -TRIG 418 -none- numeric -COPPER 418 -none- numeric -> str(pbc.) # has variable.labels -List of 20 - $ AGE : num [1:418] 58.8 56.4 70.1 54.7 38.1 ... - $ ALB : num [1:418] 2.6 4.14 3.48 2.54 3.53 3.98 4.09 4 3.08 2.74 ... - $ ALKPHOS : num [1:418] 1718 7395 516 6122 671 ... - $ ASCITES : num [1:418] 1 0 0 0 0 0 0 0 0 1 ... - $ BILI : num [1:418] 14.5 1.1 1.4 1.8 3.4 0.8 1 0.3 3.2 12.6 ... - $ CHOL : num [1:418] 261 302 176 244 279 248 322 280 562 200 ... - $ EDEMA : num [1:418] 1 0 1 1 0 0 0 0 0 1 ... - $ EDTRT : num [1:418] 1 0 0.5 0.5 0 0 0 0 0 1 ... - $ HEPMEG : num [1:418] 1 1 0 1 1 1 1 0 0 0 ... - $ TIME : num [1:418] 400 4500 1012 1925 1504 ... - $ PLATELET: num [1:418] 190 221 151 183 136 -9 204 373 251 302 ... - $ PROTIME : num [1:418] 12.2 10.6 12 10.3 10.9 11 9.7 11 11 11.5 ... - $ SEX : num [1:418] 1 1 0 1 1 1 1 1 1 1 ... - $ SGOT : num [1:418] 137.9 113.5 96.1 60.6 113.2 ... - $ SPIDERS : num [1:418] 1 1 0 1 1 0 0 0 1 1 ... - $ STAGE : num [1:418] 4 3 4 4 3 3 3 3 2 4 ... - $ STATUS : num [1:418] 1 0 1 1 0 1 0 1 1 1 ... - $ TRT : num [1:418] 1 1 1 1 2 2 2 2 1 2 ... - $ TRIG : num [1:418] 172 88 55 92 72 63 213 189 88 143 ... - $ COPPER : num [1:418] 156 54 210 64 143 50 52 52 79 140 ... - - attr(*, "label.table")=List of 20 - ..$ AGE : NULL - ..$ ALB : NULL - ..$ ALKPHOS : NULL - ..$ ASCITES : NULL - ..$ BILI : NULL - ..$ CHOL : NULL - ..$ EDEMA : NULL - ..$ EDTRT : NULL - ..$ HEPMEG : NULL - ..$ TIME : NULL - ..$ PLATELET: NULL - ..$ PROTIME : NULL - ..$ SEX : NULL - ..$ SGOT : NULL - ..$ SPIDERS : NULL - ..$ STAGE : NULL - ..$ STATUS : NULL - ..$ TRT : NULL - ..$ TRIG : NULL - ..$ COPPER : NULL - - attr(*, "variable.labels")= Named chr [1:20] " " " " " " " " ... - ..- attr(*, "names")= chr [1:20] "AGE" "ALB" "ALKPHOS" "ASCITES" ... -> stopifnot(all.equal(d.pbc, data.frame(pbc.), tolerance = 1e-15)) -> -> electric.s <- read.spss("electric.sav",TRUE,TRUE) -> electric.p <- read.spss("electric.por",TRUE,TRUE) -> electric.s4 <- read.spss("electric.sav",TRUE,TRUE,max.value.labels = 4) -> summary(electric.s) - CASEID FIRSTCHD AGE DBP58 - Min. : 1.00 NO CHD :120 Min. :40.0 Min. : 65.00 - 1st Qu.: 73.75 SUDDEN DEATH: 36 1st Qu.:45.0 1st Qu.: 80.00 - Median : 144.50 NONFATALMI : 72 Median :48.0 Median : 87.00 - Mean : 572.94 FATAL MI : 9 Mean :47.8 Mean : 88.79 - 3rd Qu.:1042.25 OTHER CHD : 3 3rd Qu.:51.0 3rd Qu.: 96.50 - Max. :2098.00 Max. :54.0 Max. :160.00 - NA's :1 - EDUYR CHOL58 CGT58 HT58 - Min. : 6.00 Min. :106.0 Min. : 0.00 Min. :60.90 - 1st Qu.: 9.75 1st Qu.:228.8 1st Qu.: 0.00 1st Qu.:66.50 - Median :12.00 Median :261.0 Median :10.00 Median :68.15 - Mean :11.66 Mean :264.1 Mean :11.58 Mean :68.51 - 3rd Qu.:14.00 3rd Qu.:293.2 3rd Qu.:20.00 3rd Qu.:70.20 - Max. :18.00 Max. :515.0 Max. :60.00 Max. :77.00 - NA's :28 NA's :1 - WT58 DAYOFWK VITAL10 FAMHXCVR CHD - Min. :123.0 SUNDAY : 19 ALIVE:179 NO :178 Min. :0.0 - 1st Qu.:156.0 TUESDAY : 19 DEAD : 61 YES: 62 1st Qu.:0.0 - Median :171.0 WEDNSDAY: 17 Median :0.5 - Mean :173.4 SATURDAY: 16 Mean :0.5 - 3rd Qu.:187.0 THURSDAY: 15 3rd Qu.:1.0 - Max. :278.0 (Other) : 24 Max. :1.0 - NA's :130 -> ii <- c(2,10) -> vl <- list(FIRSTCHD = c("OTHER CHD"= 6, "FATAL MI"= 5, "NONFATALMI"= 3, -+ "SUDDEN DEATH" = 2, "NO CHD" = 1), -+ DAYOFWK = c(SATURDAY=7, FRIDAY=6, THURSDAY=5, -+ WEDNSDAY=4, TUESDAY=3, MONDAY=2, SUNDAY=1)) -> stopifnot(identical(electric.s, electric.p), -+ identical(electric.s[-ii], electric.s4[-ii]), -+ identical(vl, lapply(electric.s4[ii], attr, "value.labels")), -+ identical(lapply(vl, names), -+ lapply(electric.s[ii], function(.) rev(levels(.))))) -> -> -> ## after "long label patch": -> -> invisible(Sys.setlocale (locale="C")) ## to resolve locale problem -> ldat <- read.spss("spss_long.sav", to.data.frame=TRUE) -> ldat - variable1 variable2 -1 1 1 -2 2 1 -3 2 3 -> nnms <- nms <- names(ldat) -> names(nnms) <- nms -> stopifnot(identical(nms, c("variable1", "variable2")), -+ identical(nnms, attr(ldat, "variable.labels"))) -> -> proc.time() - user system elapsed - 0.732 0.076 0.785 + +R Under development (unstable) (2017-06-20 r72822) -- "Unsuffered Consequences" +Copyright (C) 2017 The R Foundation for Statistical Computing +Platform: i386-w64-mingw32/i386 (32-bit) + +R is free software and comes with ABSOLUTELY NO WARRANTY. +You are welcome to redistribute it under certain conditions. +Type 'license()' or 'licence()' for distribution details. + +R is a collaborative project with many contributors. +Type 'contributors()' for more information and +'citation()' on how to cite R or R packages in publications. + +Type 'demo()' for some demos, 'help()' for on-line help, or +'help.start()' for an HTML browser interface to help. +Type 'q()' to quit R. + +> library(foreign) +> +> sample100 <- read.spss("sample100.sav",FALSE) +> summary(sample100) + Length Class Mode +YEAR 100 -none- numeric +DISTRICT 100 -none- numeric +CAMPUS 100 -none- numeric +DNAME 100 -none- character +CNAME 100 -none- character +SEX 100 -none- character +DISADVG 100 -none- character +ETHNICTY 100 -none- character +STUID 100 -none- character +TLIMTH 100 -none- numeric +GRADE 100 -none- numeric +> str(sample100) +List of 11 + $ YEAR : num [1:100] 99 94 94 95 96 97 98 99 94 95 ... + $ DISTRICT: num [1:100] 57914 57914 57914 57914 57914 ... + $ CAMPUS : num [1:100] 57914045 57914106 57914110 57914123 57914117 ... + $ DNAME : chr [1:100] "MESQUITE ISD " "MESQUITE ISD " "MESQUITE ISD " "MESQUITE ISD " ... + $ CNAME : chr [1:100] "A C NEW MIDDLE " "MCWHORTER EL " "RUTHERFORD EL " "JOEY M PIRRUNG " ... + $ SEX : chr [1:100] "F" "F" " " "F" ... + $ DISADVG : chr [1:100] "NO " "NO " " " "NO " ... + $ ETHNICTY: chr [1:100] "WHITE " "WHITE " " " "HISPANIC" ... + $ STUID : chr [1:100] "00614371S" "00614372S" "00614373S" "00614373S" ... + $ TLIMTH : num [1:100] 90 86 67 77 77 79 86 87 89 85 ... + $ GRADE : num [1:100] 8 3 3 4 5 6 7 8 3 4 ... + - attr(*, "label.table")=List of 11 + ..$ YEAR : NULL + ..$ DISTRICT: NULL + ..$ CAMPUS : NULL + ..$ DNAME : NULL + ..$ CNAME : NULL + ..$ SEX : NULL + ..$ DISADVG : NULL + ..$ ETHNICTY: NULL + ..$ STUID : NULL + ..$ TLIMTH : NULL + ..$ GRADE : NULL + - attr(*, "variable.labels")= Named chr [1:11] "YEAR OF ADMINISTRATION" "COUNTY DISTRICT NUMBER" "COUNTY DISTRICT CAMPUS NUMBER" "DISTRICT NAME" ... + ..- attr(*, "names")= chr [1:11] "YEAR" "DISTRICT" "CAMPUS" "DNAME" ... +> d.sample100 <- data.frame(sample100) +> summary(d.sample100) + YEAR DISTRICT CAMPUS DNAME + Min. : 94.0 Min. : 57905 Min. : 57905126 DALLAS ISD : 1 + 1st Qu.: 95.0 1st Qu.: 57914 1st Qu.: 57914046 HARMONY ISD : 1 + Median : 96.0 Median : 57914 Median : 57914112 MESQUITE ISD :96 + Mean : 115.4 Mean : 59644 Mean : 59644015 SUNNYVALE ISD : 2 + 3rd Qu.: 98.0 3rd Qu.: 57914 3rd Qu.: 57914125 + Max. :2000.0 Max. :230905 Max. :230905101 + + CNAME SEX DISADVG ETHNICTY STUID + J C AUSTIN EL :23 : 4 : 4 : 4 00614373S: 6 + R S KIMBROUGH M:12 F:62 NO :90 HISPANIC: 3 00614378S: 6 + WILKINSON MIDDL: 9 M:34 YES: 6 OTHER : 2 00614379S: 6 + VERNON PRICE EL: 7 WHITE :91 00614389S: 6 + TISINGER EL : 6 00614397S: 6 + THOMPSON EL : 5 00614403S: 6 + (Other) :38 (Other) :64 + TLIMTH GRADE + Min. :54.00 Min. :3.00 + 1st Qu.:74.00 1st Qu.:4.00 + Median :84.00 Median :5.00 + Mean :80.16 Mean :5.37 + 3rd Qu.:87.00 3rd Qu.:7.00 + Max. :93.00 Max. :8.00 + +> s100 <- sample100 +> sample100 <- read.spss("sample100.por",FALSE) +> stopifnot(identical(s100, sample100)) # no need for further summary() etc +> +> pbc <- read.spss("pbc.sav",FALSE) +> summary(pbc) + Length Class Mode +AGE 418 -none- numeric +ALB 418 -none- numeric +ALKPHOS 418 -none- numeric +ASCITES 418 -none- numeric +BILI 418 -none- numeric +CHOL 418 -none- numeric +EDEMA 418 -none- numeric +EDTRT 418 -none- numeric +HEPMEG 418 -none- numeric +TIME 418 -none- numeric +PLATELET 418 -none- numeric +PROTIME 418 -none- numeric +SEX 418 -none- numeric +SGOT 418 -none- numeric +SPIDERS 418 -none- numeric +STAGE 418 -none- numeric +STATUS 418 -none- numeric +TRT 418 -none- numeric +TRIG 418 -none- numeric +COPPER 418 -none- numeric +> str(pbc) +List of 20 + $ AGE : num [1:418] 58.8 56.4 70.1 54.7 38.1 ... + $ ALB : num [1:418] 2.6 4.14 3.48 2.54 3.53 3.98 4.09 4 3.08 2.74 ... + $ ALKPHOS : num [1:418] 1718 7395 516 6122 671 ... + $ ASCITES : num [1:418] 1 0 0 0 0 0 0 0 0 1 ... + $ BILI : num [1:418] 14.5 1.1 1.4 1.8 3.4 0.8 1 0.3 3.2 12.6 ... + $ CHOL : num [1:418] 261 302 176 244 279 248 322 280 562 200 ... + $ EDEMA : num [1:418] 1 0 1 1 0 0 0 0 0 1 ... + $ EDTRT : num [1:418] 1 0 0.5 0.5 0 0 0 0 0 1 ... + $ HEPMEG : num [1:418] 1 1 0 1 1 1 1 0 0 0 ... + $ TIME : num [1:418] 400 4500 1012 1925 1504 ... + $ PLATELET: num [1:418] 190 221 151 183 136 -9 204 373 251 302 ... + $ PROTIME : num [1:418] 12.2 10.6 12 10.3 10.9 11 9.7 11 11 11.5 ... + $ SEX : num [1:418] 1 1 0 1 1 1 1 1 1 1 ... + $ SGOT : num [1:418] 137.9 113.5 96.1 60.6 113.2 ... + $ SPIDERS : num [1:418] 1 1 0 1 1 0 0 0 1 1 ... + $ STAGE : num [1:418] 4 3 4 4 3 3 3 3 2 4 ... + $ STATUS : num [1:418] 1 0 1 1 0 1 0 1 1 1 ... + $ TRT : num [1:418] 1 1 1 1 2 2 2 2 1 2 ... + $ TRIG : num [1:418] 172 88 55 92 72 63 213 189 88 143 ... + $ COPPER : num [1:418] 156 54 210 64 143 50 52 52 79 140 ... + - attr(*, "label.table")=List of 20 + ..$ AGE : NULL + ..$ ALB : NULL + ..$ ALKPHOS : NULL + ..$ ASCITES : NULL + ..$ BILI : NULL + ..$ CHOL : NULL + ..$ EDEMA : NULL + ..$ EDTRT : NULL + ..$ HEPMEG : NULL + ..$ TIME : NULL + ..$ PLATELET: NULL + ..$ PROTIME : NULL + ..$ SEX : NULL + ..$ SGOT : NULL + ..$ SPIDERS : NULL + ..$ STAGE : NULL + ..$ STATUS : NULL + ..$ TRT : NULL + ..$ TRIG : NULL + ..$ COPPER : NULL +> d.pbc <- data.frame(pbc) +> summary(d.pbc) + AGE ALB ALKPHOS ASCITES + Min. :26.28 Min. :1.960 Min. : -9 Min. :-9.000 + 1st Qu.:42.83 1st Qu.:3.243 1st Qu.: -9 1st Qu.:-9.000 + Median :51.00 Median :3.530 Median : 1009 Median : 0.000 + Mean :50.74 Mean :3.497 Mean : 1478 Mean :-2.225 + 3rd Qu.:58.24 3rd Qu.:3.770 3rd Qu.: 1708 3rd Qu.: 0.000 + Max. :78.44 Max. :4.640 Max. :13862 Max. : 1.000 + BILI CHOL EDEMA EDTRT + Min. : 0.300 Min. : -9.0 Min. :0.0000 Min. :0.0000 + 1st Qu.: 0.800 1st Qu.: -9.0 1st Qu.:0.0000 1st Qu.:0.0000 + Median : 1.400 Median : 252.5 Median :0.0000 Median :0.0000 + Mean : 3.221 Mean : 248.2 Mean :0.1196 Mean :0.1005 + 3rd Qu.: 3.400 3rd Qu.: 347.8 3rd Qu.:0.0000 3rd Qu.:0.0000 + Max. :28.000 Max. :1775.0 Max. :1.0000 Max. :1.0000 + HEPMEG TIME PLATELET PROTIME SEX + Min. :-9.0 Min. : 41 Min. : -9.0 Min. : 9.00 Min. :-9.000 + 1st Qu.:-9.0 1st Qu.:1093 1st Qu.:181.0 1st Qu.:10.00 1st Qu.:-9.000 + Median : 0.0 Median :1730 Median :248.0 Median :10.60 Median : 1.000 + Mean :-1.9 Mean :1918 Mean :250.0 Mean :10.73 Mean :-1.622 + 3rd Qu.: 1.0 3rd Qu.:2614 3rd Qu.:315.5 3rd Qu.:11.10 3rd Qu.: 1.000 + Max. : 1.0 Max. :4795 Max. :721.0 Max. :18.00 Max. : 1.000 + SGOT SPIDERS STAGE STATUS + Min. : -9.00 Min. :-9.000 Min. :-9.00000 Min. :0.0000 + 1st Qu.: -9.00 1st Qu.:-9.000 1st Qu.:-9.00000 1st Qu.:0.0000 + Median : 90.45 Median : 0.000 Median : 3.00000 Median :0.0000 + Mean : 89.20 Mean :-2.067 Mean :-0.01914 Mean :0.3852 + 3rd Qu.:135.75 3rd Qu.: 0.000 3rd Qu.: 4.00000 3rd Qu.:1.0000 + Max. :457.25 Max. : 1.000 Max. : 4.00000 Max. :1.0000 + TRT TRIG COPPER + Min. :-9.000 Min. : -9.0 Min. : -9.00 + 1st Qu.:-9.000 1st Qu.: -9.0 1st Qu.: -9.00 + Median : 1.000 Median : 85.0 Median : 50.50 + Mean :-1.167 Mean : 81.2 Mean : 70.09 + 3rd Qu.: 2.000 3rd Qu.:127.8 3rd Qu.:100.75 + Max. : 2.000 Max. :598.0 Max. :588.00 +> pbco <- read.spss("pbcold.sav",FALSE) +> stopifnot(identical(pbc, pbco)) +> ## summary(pbco) +> ## str(pbco) +> ## d.pbco <- data.frame(pbco) +> ## summary(d.pbco) +> pbc. <- read.spss("pbc.por",FALSE) +> summary(pbc.) + Length Class Mode +AGE 418 -none- numeric +ALB 418 -none- numeric +ALKPHOS 418 -none- numeric +ASCITES 418 -none- numeric +BILI 418 -none- numeric +CHOL 418 -none- numeric +EDEMA 418 -none- numeric +EDTRT 418 -none- numeric +HEPMEG 418 -none- numeric +TIME 418 -none- numeric +PLATELET 418 -none- numeric +PROTIME 418 -none- numeric +SEX 418 -none- numeric +SGOT 418 -none- numeric +SPIDERS 418 -none- numeric +STAGE 418 -none- numeric +STATUS 418 -none- numeric +TRT 418 -none- numeric +TRIG 418 -none- numeric +COPPER 418 -none- numeric +> str(pbc.) # has variable.labels +List of 20 + $ AGE : num [1:418] 58.8 56.4 70.1 54.7 38.1 ... + $ ALB : num [1:418] 2.6 4.14 3.48 2.54 3.53 3.98 4.09 4 3.08 2.74 ... + $ ALKPHOS : num [1:418] 1718 7395 516 6122 671 ... + $ ASCITES : num [1:418] 1 0 0 0 0 0 0 0 0 1 ... + $ BILI : num [1:418] 14.5 1.1 1.4 1.8 3.4 0.8 1 0.3 3.2 12.6 ... + $ CHOL : num [1:418] 261 302 176 244 279 248 322 280 562 200 ... + $ EDEMA : num [1:418] 1 0 1 1 0 0 0 0 0 1 ... + $ EDTRT : num [1:418] 1 0 0.5 0.5 0 0 0 0 0 1 ... + $ HEPMEG : num [1:418] 1 1 0 1 1 1 1 0 0 0 ... + $ TIME : num [1:418] 400 4500 1012 1925 1504 ... + $ PLATELET: num [1:418] 190 221 151 183 136 -9 204 373 251 302 ... + $ PROTIME : num [1:418] 12.2 10.6 12 10.3 10.9 11 9.7 11 11 11.5 ... + $ SEX : num [1:418] 1 1 0 1 1 1 1 1 1 1 ... + $ SGOT : num [1:418] 137.9 113.5 96.1 60.6 113.2 ... + $ SPIDERS : num [1:418] 1 1 0 1 1 0 0 0 1 1 ... + $ STAGE : num [1:418] 4 3 4 4 3 3 3 3 2 4 ... + $ STATUS : num [1:418] 1 0 1 1 0 1 0 1 1 1 ... + $ TRT : num [1:418] 1 1 1 1 2 2 2 2 1 2 ... + $ TRIG : num [1:418] 172 88 55 92 72 63 213 189 88 143 ... + $ COPPER : num [1:418] 156 54 210 64 143 50 52 52 79 140 ... + - attr(*, "label.table")=List of 20 + ..$ AGE : NULL + ..$ ALB : NULL + ..$ ALKPHOS : NULL + ..$ ASCITES : NULL + ..$ BILI : NULL + ..$ CHOL : NULL + ..$ EDEMA : NULL + ..$ EDTRT : NULL + ..$ HEPMEG : NULL + ..$ TIME : NULL + ..$ PLATELET: NULL + ..$ PROTIME : NULL + ..$ SEX : NULL + ..$ SGOT : NULL + ..$ SPIDERS : NULL + ..$ STAGE : NULL + ..$ STATUS : NULL + ..$ TRT : NULL + ..$ TRIG : NULL + ..$ COPPER : NULL + - attr(*, "variable.labels")= Named chr [1:20] " " " " " " " " ... + ..- attr(*, "names")= chr [1:20] "AGE" "ALB" "ALKPHOS" "ASCITES" ... +> stopifnot(all.equal(d.pbc, data.frame(pbc.), tolerance = 1e-15)) +> +> electric.s <- read.spss(system.file("files", "electric.sav", package = "foreign"), TRUE, TRUE) +> electric.p <- read.spss("electric.por",TRUE,TRUE) +> electric.s4 <- read.spss(system.file("files", "electric.sav", package = "foreign"), TRUE, TRUE, max.value.labels = 4) +> summary(electric.s) + CASEID FIRSTCHD AGE DBP58 + Min. : 1.00 NO CHD :120 Min. :40.0 Min. : 65.00 + 1st Qu.: 73.75 SUDDEN DEATH: 36 1st Qu.:45.0 1st Qu.: 80.00 + Median : 144.50 NONFATALMI : 72 Median :48.0 Median : 87.00 + Mean : 572.94 FATAL MI : 9 Mean :47.8 Mean : 88.79 + 3rd Qu.:1042.25 OTHER CHD : 3 3rd Qu.:51.0 3rd Qu.: 96.50 + Max. :2098.00 Max. :54.0 Max. :160.00 + NA's :1 + EDUYR CHOL58 CGT58 HT58 + Min. : 6.00 Min. :106.0 Min. : 0.00 Min. :60.90 + 1st Qu.: 9.75 1st Qu.:228.8 1st Qu.: 0.00 1st Qu.:66.50 + Median :12.00 Median :261.0 Median :10.00 Median :68.15 + Mean :11.66 Mean :264.1 Mean :11.58 Mean :68.51 + 3rd Qu.:14.00 3rd Qu.:293.2 3rd Qu.:20.00 3rd Qu.:70.20 + Max. :18.00 Max. :515.0 Max. :60.00 Max. :77.00 + NA's :28 NA's :1 + WT58 DAYOFWK VITAL10 FAMHXCVR CHD + Min. :123.0 SUNDAY : 19 ALIVE:179 NO :178 Min. :0.0 + 1st Qu.:156.0 TUESDAY : 19 DEAD : 61 YES: 62 1st Qu.:0.0 + Median :171.0 WEDNSDAY: 17 Median :0.5 + Mean :173.4 SATURDAY: 16 Mean :0.5 + 3rd Qu.:187.0 THURSDAY: 15 3rd Qu.:1.0 + Max. :278.0 (Other) : 24 Max. :1.0 + NA's :130 +> ii <- c(2,10) +> vl <- list(FIRSTCHD = c("OTHER CHD"= 6, "FATAL MI"= 5, "NONFATALMI"= 3, ++ "SUDDEN DEATH" = 2, "NO CHD" = 1), ++ DAYOFWK = c(SATURDAY=7, FRIDAY=6, THURSDAY=5, ++ WEDNSDAY=4, TUESDAY=3, MONDAY=2, SUNDAY=1)) +> stopifnot(identical(electric.s, electric.p), ++ identical(electric.s[-ii], electric.s4[-ii]), ++ identical(vl, lapply(electric.s4[ii], attr, "value.labels")), ++ identical(lapply(vl, names), ++ lapply(electric.s[ii], function(.) rev(levels(.))))) +> +> +> ## after "long label patch": +> +> invisible(Sys.setlocale (locale="C")) ## to resolve locale problem +> ldat <- read.spss("spss_long.sav", to.data.frame=TRUE) +> ldat + variable1 variable2 +1 1 1 +2 2 1 +3 2 3 +> nnms <- nms <- names(ldat) +> names(nnms) <- nms +> stopifnot(identical(nms, c("variable1", "variable2")), ++ identical(nnms, attr(ldat, "variable.labels"))) +> +> +> ## some new arkward testcases for problems found in foreign <= 0.8-68 and duplicated value labels in general: +> +> ## Expect lots of warnings as value labels (corresponding to R factor labels) are uncomplete, +> ## and an unsupported long string variable is present in the data +> +> setwd(system.file("files", package = "foreign")) +> sav <- "testdata.sav" +> +> x.nodat <- read.spss(file=sav, to.data.frame = FALSE, reencode="UTF-8") +re-encoding from UTF-8 +Warning messages: +1: In read.spss(file = sav, to.data.frame = FALSE, reencode = "UTF-8") : + testdata.sav: Very long string record(s) found (record type 7, subtype 14), each will be imported in consecutive separate variables +2: In read.spss(file = sav, to.data.frame = FALSE, reencode = "UTF-8") : + Undeclared level(s) -1 added in variable: factor_numeric +3: In read.spss(file = sav, to.data.frame = FALSE, reencode = "UTF-8") : + Duplicated levels in factor factor_n_duplicated: A +4: In read.spss(file = sav, to.data.frame = FALSE, reencode = "UTF-8") : + Undeclared level(s) 2, 3, 4 added in variable: factor_n_undeclared +5: In read.spss(file = sav, to.data.frame = FALSE, reencode = "UTF-8") : + Undeclared level(s) 0, 3 added in variable: factor_n_undeclared2 +6: In read.spss(file = sav, to.data.frame = FALSE, reencode = "UTF-8") : + Undeclared level(s) .. added in variable: factor_s_duplicated +7: In read.spss(file = sav, to.data.frame = FALSE, reencode = "UTF-8") : + Duplicated levels in factor factor_s_duplicated: A +8: In read.spss(file = sav, to.data.frame = FALSE, reencode = "UTF-8") : + Undeclared level(s) perhaps added in variable: factor_s_undeclared +> str(x.nodat) +List of 17 + $ numeric : num [1:5] 1 2 3 NA 3 + $ numeric_long_label : num [1:5] 1 2 3.33 4 NA + $ factor_numeric : Factor w/ 6 levels "-1","strongly disagree",..: 2 3 4 1 NA + $ factor_n_long_value_label: Factor w/ 2 levels "abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnop",..: 1 2 NA 2 1 + $ factor_n_coded_miss : Factor w/ 6 levels "strongly disagree",..: 1 2 6 5 NA + $ factor_n_duplicated : Factor w/ 3 levels "A","A_duplicated_2",..: 1 1 2 NA 3 + $ factor_n_undeclared : Factor w/ 5 levels "strongly disagree",..: 1 2 4 3 1 + $ factor_n_undeclared2 : Factor w/ 4 levels "0","yes","no",..: 1 4 NA 1 4 + $ string : chr [1:5] "Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo ligula eget dolor. Aenean massa. Cum s"| __truncated__ "One morning, when Gregor Samsa woke from troubled dreams, he found himself transformed in his bed into a horrib"| __truncated__ " "| __truncated__ " "| __truncated__ ... + $ string_500 : chr [1:5] "A wonderful serenity has taken possession of my entire soul, like these sweet mornings of spring which I enjoy "| __truncated__ " "| __truncated__ "Far far away, behind the word mountains, far from the countries Vokalia and Consonantia, there live the blind t"| __truncated__ " "| __truncated__ ... + $ STRIN0 : chr [1:5] ", my dear friend, so absorbed in the exquisite sense of mere tranquil existence, that I neglect my talents. I s"| __truncated__ " "| __truncated__ "r place and supplies it with the necessary regelialia. It is a paradisematic country, in which roasted parts of"| __truncated__ " "| __truncated__ ... + $ string_miss : chr [1:5] "a " "c " "b " "g " ... + $ factor_s_coded_miss : Factor w/ 3 levels "female","male",..: 2 1 NA 2 3 + $ factor_s_duplicated : Factor w/ 4 levels "..","A","A_duplicated_b",..: 2 1 1 NA NA + $ factor_s_undeclared : Factor w/ 3 levels "no","perhaps",..: 3 1 2 NA 3 + $ factor_s_undeclared2 : Factor w/ 2 levels "no","yes": NA NA NA NA NA + $ date : num [1:5] 1.27e+10 1.37e+10 1.37e+10 NA NA + - attr(*, "label.table")=List of 17 + ..$ numeric : NULL + ..$ numeric_long_label : NULL + ..$ factor_numeric : Named chr [1:5] "5" "4" "3" "2" ... + .. ..- attr(*, "names")= chr [1:5] "strongly agree" "agree" "neither agree nor disagree" "disagree" ... + ..$ factor_n_long_value_label: Named chr [1:2] "2" "1" + .. ..- attr(*, "names")= chr [1:2] "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789 ! \" # $ % & ' ( ) * + , - . / : ; < = > ? @ [ \\ ] ^ _ ` { | } ~ ..." "abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnop" + ..$ factor_n_coded_miss : Named chr [1:6] "99" "5" "4" "3" ... + .. ..- attr(*, "names")= chr [1:6] "no answer" "strongly agree" "agree" "neither agree nor disagree" ... + ..$ factor_n_duplicated : Named chr [1:3] "3" "2" "1" + .. ..- attr(*, "names")= chr [1:3] "B" "A" "A" + ..$ factor_n_undeclared : Named chr [1:2] "5" "1" + .. ..- attr(*, "names")= chr [1:2] "strongly agree" "strongly disagree" + ..$ factor_n_undeclared2 : Named chr [1:2] "2" "1" + .. ..- attr(*, "names")= chr [1:2] "no" "yes" + ..$ string : NULL + ..$ string_500 : NULL + ..$ STRIN0 : NULL + ..$ string_miss : NULL + ..$ factor_s_coded_miss : Named chr [1:3] "u " "m " "f " + .. ..- attr(*, "names")= chr [1:3] "unknown" "male" "female" + ..$ factor_s_duplicated : Named chr [1:3] "c " "b " "a " + .. ..- attr(*, "names")= chr [1:3] "C" "A" "A" + ..$ factor_s_undeclared : Named chr [1:2] "y " "n " + .. ..- attr(*, "names")= chr [1:2] "yes" "no" + ..$ factor_s_undeclared2 : Named chr [1:2] "y " "n " + .. ..- attr(*, "names")= chr [1:2] "yes" "no" + ..$ date : NULL + - attr(*, "variable.labels")= Named chr [1:17] "numeric variable" "numeric variable with long label: this variable hat five observations (one is missing). All values between 1 an"| __truncated__ "numeric factor with missing range" "numeric factor with long value labels" ... + ..- attr(*, "names")= chr [1:17] "numeric" "numeric_long_label" "factor_numeric" "factor_n_long_value_label" ... + - attr(*, "missings")=List of 17 + ..$ numeric :List of 1 + .. ..$ type: chr "none" + ..$ numeric_long_label :List of 2 + .. ..$ type : chr "range" + .. ..$ value: num [1:2] 1 2 + ..$ factor_numeric :List of 2 + .. ..$ type : chr "range" + .. ..$ value: num [1:2] -1 0 + ..$ factor_n_long_value_label:List of 1 + .. ..$ type: chr "none" + ..$ factor_n_coded_miss :List of 2 + .. ..$ type : chr "one" + .. ..$ value: num 99 + ..$ factor_n_duplicated :List of 1 + .. ..$ type: chr "none" + ..$ factor_n_undeclared :List of 1 + .. ..$ type: chr "none" + ..$ factor_n_undeclared2 :List of 1 + .. ..$ type: chr "none" + ..$ string :List of 1 + .. ..$ type: chr "none" + ..$ string_500 :List of 1 + .. ..$ type: chr "none" + ..$ STRIN0 :List of 1 + .. ..$ type: chr "none" + ..$ string_miss :List of 2 + .. ..$ type : chr "two" + .. ..$ value: chr [1:2] "a b " "b " + ..$ factor_s_coded_miss :List of 2 + .. ..$ type : chr "three" + .. ..$ value: chr [1:3] "u v w \b" "v w \b" "w \b" + ..$ factor_s_duplicated :List of 1 + .. ..$ type: chr "none" + ..$ factor_s_undeclared :List of 1 + .. ..$ type: chr "none" + ..$ factor_s_undeclared2 :List of 1 + .. ..$ type: chr "none" + ..$ date :List of 1 + .. ..$ type: chr "none" + - attr(*, "codepage")= int 65001 +> +> x.sort <- read.spss(file=sav, to.data.frame = TRUE, reencode="UTF-8") +re-encoding from UTF-8 +Warning messages: +1: In read.spss(file = sav, to.data.frame = TRUE, reencode = "UTF-8") : + testdata.sav: Very long string record(s) found (record type 7, subtype 14), each will be imported in consecutive separate variables +2: In read.spss(file = sav, to.data.frame = TRUE, reencode = "UTF-8") : + Duplicated levels in factor factor_n_duplicated: A +3: In read.spss(file = sav, to.data.frame = TRUE, reencode = "UTF-8") : + Undeclared level(s) 2, 3, 4 added in variable: factor_n_undeclared +4: In read.spss(file = sav, to.data.frame = TRUE, reencode = "UTF-8") : + Undeclared level(s) 0, 3 added in variable: factor_n_undeclared2 +5: In read.spss(file = sav, to.data.frame = TRUE, reencode = "UTF-8") : + Undeclared level(s) .. added in variable: factor_s_duplicated +6: In read.spss(file = sav, to.data.frame = TRUE, reencode = "UTF-8") : + Duplicated levels in factor factor_s_duplicated: A +7: In read.spss(file = sav, to.data.frame = TRUE, reencode = "UTF-8") : + Undeclared level(s) perhaps added in variable: factor_s_undeclared +> str(x.sort) +'data.frame': 5 obs. of 17 variables: + $ numeric : num 1 2 3 NA 3 + $ numeric_long_label : num NA NA 3.33 4 NA + $ factor_numeric : Factor w/ 5 levels "strongly disagree",..: 1 2 3 NA NA + $ factor_n_long_value_label: Factor w/ 2 levels "abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnop",..: 1 2 NA 2 1 + $ factor_n_coded_miss : Factor w/ 5 levels "strongly disagree",..: 1 2 NA 5 NA + $ factor_n_duplicated : Factor w/ 3 levels "A","A_duplicated_2",..: 1 1 2 NA 3 + $ factor_n_undeclared : Factor w/ 5 levels "strongly disagree",..: 1 2 4 3 1 + $ factor_n_undeclared2 : Factor w/ 4 levels "0","yes","no",..: 1 4 NA 1 4 + $ string : Factor w/ 4 levels " "| __truncated__,..: 3 4 1 1 2 + $ string_500 : Factor w/ 4 levels " "| __truncated__,..: 2 1 3 1 4 + $ STRIN0 : Factor w/ 4 levels " "| __truncated__,..: 2 1 4 1 3 + $ string_miss : Factor w/ 4 levels " ","a ",..: 2 3 NA 4 1 + $ factor_s_coded_miss : Factor w/ 3 levels "female","male",..: 2 1 NA 2 3 + $ factor_s_duplicated : Factor w/ 4 levels "..","A","A_duplicated_b",..: 2 1 1 NA NA + $ factor_s_undeclared : Factor w/ 3 levels "no","perhaps",..: 3 1 2 NA 3 + $ factor_s_undeclared2 : Factor w/ 2 levels "no","yes": NA NA NA NA NA + $ date : num 1.27e+10 1.37e+10 1.37e+10 NA NA + - attr(*, "variable.labels")= Named chr "numeric variable" "numeric variable with long label: this variable hat five observations (one is missing). All values between 1 an"| __truncated__ "numeric factor with missing range" "numeric factor with long value labels" ... + ..- attr(*, "names")= chr "numeric" "numeric_long_label" "factor_numeric" "factor_n_long_value_label" ... + - attr(*, "codepage")= int 65001 +> x.append <- read.spss(file=sav, to.data.frame = TRUE, ++ add.undeclared.levels = "append", reencode="UTF-8") +re-encoding from UTF-8 +Warning messages: +1: In read.spss(file = sav, to.data.frame = TRUE, add.undeclared.levels = "append", : + testdata.sav: Very long string record(s) found (record type 7, subtype 14), each will be imported in consecutive separate variables +2: In read.spss(file = sav, to.data.frame = TRUE, add.undeclared.levels = "append", : + Duplicated levels in factor factor_n_duplicated: A +3: In read.spss(file = sav, to.data.frame = TRUE, add.undeclared.levels = "append", : + Undeclared level(s) 2, 3, 4 added in variable: factor_n_undeclared +4: In read.spss(file = sav, to.data.frame = TRUE, add.undeclared.levels = "append", : + Undeclared level(s) 0, 3 added in variable: factor_n_undeclared2 +5: In read.spss(file = sav, to.data.frame = TRUE, add.undeclared.levels = "append", : + Undeclared level(s) .. added in variable: factor_s_duplicated +6: In read.spss(file = sav, to.data.frame = TRUE, add.undeclared.levels = "append", : + Duplicated levels in factor factor_s_duplicated: A +7: In read.spss(file = sav, to.data.frame = TRUE, add.undeclared.levels = "append", : + Undeclared level(s) perhaps added in variable: factor_s_undeclared +> x.no <- read.spss(file=sav, to.data.frame = TRUE, ++ add.undeclared.levels = "no", reencode="UTF-8") +re-encoding from UTF-8 +Warning messages: +1: In read.spss(file = sav, to.data.frame = TRUE, add.undeclared.levels = "no", : + testdata.sav: Very long string record(s) found (record type 7, subtype 14), each will be imported in consecutive separate variables +2: In read.spss(file = sav, to.data.frame = TRUE, add.undeclared.levels = "no", : + Duplicated levels in factor factor_n_duplicated: A +> +> levels(x.sort$factor_n_undeclared) +[1] "strongly disagree" "2" "3" +[4] "4" "strongly agree" +> levels(x.append$factor_n_undeclared) +[1] "strongly disagree" "strongly agree" "2" +[4] "3" "4" +> str(x.no$factor_n_undeclared) + atomic [1:5] 1 2 4 3 1 + - attr(*, "value.labels")= Named chr [1:2] "5" "1" + ..- attr(*, "names")= chr [1:2] "strongly agree" "strongly disagree" +> +> +> ### Examples for duplicated.value.labels: +> ## duplicated.value.labels = "append" (default) +> x.append <- read.spss(file=sav, to.data.frame=TRUE, reencode="UTF-8") +re-encoding from UTF-8 +Warning messages: +1: In read.spss(file = sav, to.data.frame = TRUE, reencode = "UTF-8") : + testdata.sav: Very long string record(s) found (record type 7, subtype 14), each will be imported in consecutive separate variables +2: In read.spss(file = sav, to.data.frame = TRUE, reencode = "UTF-8") : + Duplicated levels in factor factor_n_duplicated: A +3: In read.spss(file = sav, to.data.frame = TRUE, reencode = "UTF-8") : + Undeclared level(s) 2, 3, 4 added in variable: factor_n_undeclared +4: In read.spss(file = sav, to.data.frame = TRUE, reencode = "UTF-8") : + Undeclared level(s) 0, 3 added in variable: factor_n_undeclared2 +5: In read.spss(file = sav, to.data.frame = TRUE, reencode = "UTF-8") : + Undeclared level(s) .. added in variable: factor_s_duplicated +6: In read.spss(file = sav, to.data.frame = TRUE, reencode = "UTF-8") : + Duplicated levels in factor factor_s_duplicated: A +7: In read.spss(file = sav, to.data.frame = TRUE, reencode = "UTF-8") : + Undeclared level(s) perhaps added in variable: factor_s_undeclared +> ## duplicated.value.labels = "condense" +> x.condense <- read.spss(file=sav, to.data.frame=TRUE, ++ duplicated.value.labels = "condense", reencode="UTF-8") +re-encoding from UTF-8 +Warning messages: +1: In read.spss(file = sav, to.data.frame = TRUE, duplicated.value.labels = "condense", : + testdata.sav: Very long string record(s) found (record type 7, subtype 14), each will be imported in consecutive separate variables +2: In read.spss(file = sav, to.data.frame = TRUE, duplicated.value.labels = "condense", : + Duplicated levels in factor factor_n_duplicated: A +3: In read.spss(file = sav, to.data.frame = TRUE, duplicated.value.labels = "condense", : + Undeclared level(s) 2, 3, 4 added in variable: factor_n_undeclared +4: In read.spss(file = sav, to.data.frame = TRUE, duplicated.value.labels = "condense", : + Undeclared level(s) 0, 3 added in variable: factor_n_undeclared2 +5: In read.spss(file = sav, to.data.frame = TRUE, duplicated.value.labels = "condense", : + Undeclared level(s) .. added in variable: factor_s_duplicated +6: In read.spss(file = sav, to.data.frame = TRUE, duplicated.value.labels = "condense", : + Duplicated levels in factor factor_s_duplicated: A +7: In read.spss(file = sav, to.data.frame = TRUE, duplicated.value.labels = "condense", : + Undeclared level(s) perhaps added in variable: factor_s_undeclared +> +> levels(x.append$factor_n_duplicated) +[1] "A" "A_duplicated_2" "B" +> levels(x.condense$factor_n_duplicated) +[1] "A" "B" +> +> as.numeric(x.append$factor_n_duplicated) +[1] 1 1 2 NA 3 +> as.numeric(x.condense$factor_n_duplicated) +[1] 1 1 1 NA 2 +> +> ### ToDo: +> ## Long Strings (>255 chars) are imported in consecutive separate variables +> ## (see warning about subtype 14) +> ## we should get that right in the import function in future versions +> x <- read.spss(file=sav, to.data.frame=TRUE, stringsAsFactors=FALSE, reencode="UTF-8") +re-encoding from UTF-8 +Warning messages: +1: In read.spss(file = sav, to.data.frame = TRUE, stringsAsFactors = FALSE, : + testdata.sav: Very long string record(s) found (record type 7, subtype 14), each will be imported in consecutive separate variables +2: In read.spss(file = sav, to.data.frame = TRUE, stringsAsFactors = FALSE, : + Duplicated levels in factor factor_n_duplicated: A +3: In read.spss(file = sav, to.data.frame = TRUE, stringsAsFactors = FALSE, : + Undeclared level(s) 2, 3, 4 added in variable: factor_n_undeclared +4: In read.spss(file = sav, to.data.frame = TRUE, stringsAsFactors = FALSE, : + Undeclared level(s) 0, 3 added in variable: factor_n_undeclared2 +5: In read.spss(file = sav, to.data.frame = TRUE, stringsAsFactors = FALSE, : + Undeclared level(s) .. added in variable: factor_s_duplicated +6: In read.spss(file = sav, to.data.frame = TRUE, stringsAsFactors = FALSE, : + Duplicated levels in factor factor_s_duplicated: A +7: In read.spss(file = sav, to.data.frame = TRUE, stringsAsFactors = FALSE, : + Undeclared level(s) perhaps added in variable: factor_s_undeclared +> +> cat.long.string <- function(x, w=70) cat(paste(strwrap(x, width=w), "\n")) +> +> ## first part: x$string_500: +> cat.long.string(x$string_500) +A wonderful serenity has taken possession of my entire soul, like + these sweet mornings of spring which I enjoy with my whole heart. I + am alone, and feel the charm of existence in this spot, which was + created for the bliss of souls like mine. I am so happy + + Far far away, behind the word mountains, far from the countries + Vokalia and Consonantia, there live the blind texts. Separated they + live in Bookmarksgrove right at the coast of the Semantics, a large + language ocean. A small river named Duden flows by thei + + abc def ghi jkl mno pqrs tuv wxyz ABC DEF GHI JKL MNO PQRS TUV WXYZ + !".. $%& /() =?* '<> #|; ....~ @`.. ...... ...... {} abc def ghi jkl + mno pqrs tuv wxyz ABC DEF GHI JKL MNO PQRS TUV WXYZ !".. $%& /() =?* + '<> #|; ....~ @`.. ...... ...... {} abc def ghi j +> ## second part: x$STRIN0: +> cat.long.string(x$STRIN0) +, my dear friend, so absorbed in the exquisite sense of mere tranquil + existence, that I neglect my talents. I should be incapable of + drawing a single stroke at the present moment; and yet I feel that I + never was a greater artist than now. + + r place and supplies it with the necessary regelialia. It is a + paradisematic country, in which roasted parts of sentences fly into + your mouth. + + kl mno pqrs tuv wxyz ABC DEF GHI JKL MNO PQRS TUV WXYZ !".. $%& /() + =?* '<> #|; ....~ @`.. ...... ...... {} abc def ghi jkl mno pqrs tuv + wxyz ABC DEF GHI JKL MNO PQRS TUV WXYZ !".. $%& /() =?* '<> #|; ....~ + @`.. ...... ...... {} abc def ghi jkl +> ## complete long string: +> long.string <- apply(x[,c("string_500", "STRIN0")], 1, paste, collapse="") +> cat.long.string(long.string) +A wonderful serenity has taken possession of my entire soul, like + these sweet mornings of spring which I enjoy with my whole heart. I + am alone, and feel the charm of existence in this spot, which was + created for the bliss of souls like mine. I am so happy, my dear + friend, so absorbed in the exquisite sense of mere tranquil + existence, that I neglect my talents. I should be incapable of + drawing a single stroke at the present moment; and yet I feel that I + never was a greater artist than now. + + Far far away, behind the word mountains, far from the countries + Vokalia and Consonantia, there live the blind texts. Separated they + live in Bookmarksgrove right at the coast of the Semantics, a large + language ocean. A small river named Duden flows by their place and + supplies it with the necessary regelialia. It is a paradisematic + country, in which roasted parts of sentences fly into your mouth. + + abc def ghi jkl mno pqrs tuv wxyz ABC DEF GHI JKL MNO PQRS TUV WXYZ + !".. $%& /() =?* '<> #|; ....~ @`.. ...... ...... {} abc def ghi jkl + mno pqrs tuv wxyz ABC DEF GHI JKL MNO PQRS TUV WXYZ !".. $%& /() =?* + '<> #|; ....~ @`.. ...... ...... {} abc def ghi jkl mno pqrs tuv wxyz + ABC DEF GHI JKL MNO PQRS TUV WXYZ !".. $%& /() =?* '<> #|; ....~ @`.. + ...... ...... {} abc def ghi jkl mno pqrs tuv wxyz ABC DEF GHI JKL + MNO PQRS TUV WXYZ !".. $%& /() =?* '<> #|; ....~ @`.. ...... ...... + {} abc def ghi jkl +> +> proc.time() + user system elapsed + 0.82 0.09 1.06