R Under development (unstable) (2013-07-06 r63202) -- "Unsuffered Consequences" Copyright (C) 2013 The R Foundation for Statistical Computing Platform: x86_64-apple-darwin12.4.0 (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. > ## regression test for PR#15346 > > library(foreign) > > ## The testEmpty.xpt dataset was created using the following code: > ## library(SASxport) > ## data(iris) > ## write.xport(Iris1=iris[1:2,], # two row dataset > ## empty=data.frame(), # empty dataset > ## Iris2=iris[3:4,], # two row dataset > ## file="testEmpty.xpt", > ## autogen.formats=FALSE # prevent autocreation of FORMATS dataset > ## ) > > ## Test that lookup.xport retrieves all three datsets > empty.f <- lookup.xport(file="testEmpty.xpt") > empty.f $IRIS1 $IRIS1$headpad [1] 1200 $IRIS1$type [1] "numeric" "numeric" "numeric" "numeric" "character" $IRIS1$width [1] 8 8 8 8 8 $IRIS1$index [1] 1 2 3 4 5 $IRIS1$position [1] 0 8 16 24 32 $IRIS1$name [1] "SEPAL_LE" "SEPAL_WI" "PETAL_LE" "PETAL_WI" "SPECIES" $IRIS1$label [1] "" "" "" "" "" $IRIS1$format [1] "" "" "" "" "" $IRIS1$sexptype [1] 14 14 14 14 16 $IRIS1$tailpad [1] 0 $IRIS1$length [1] 2 $EMPTY $EMPTY$headpad [1] 480 $EMPTY$type character(0) $EMPTY$width integer(0) $EMPTY$index integer(0) $EMPTY$position integer(0) $EMPTY$name character(0) $EMPTY$label character(0) $EMPTY$format character(0) $EMPTY$sexptype integer(0) $EMPTY$tailpad [1] 0 $EMPTY$length [1] 0 $IRIS2 $IRIS2$headpad [1] 1200 $IRIS2$type [1] "numeric" "numeric" "numeric" "numeric" "character" $IRIS2$width [1] 8 8 8 8 8 $IRIS2$index [1] 1 2 3 4 5 $IRIS2$position [1] 0 8 16 24 32 $IRIS2$name [1] "SEPAL_LE" "SEPAL_WI" "PETAL_LE" "PETAL_WI" "SPECIES" $IRIS2$label [1] "" "" "" "" "" $IRIS2$format [1] "" "" "" "" "" $IRIS2$sexptype [1] 14 14 14 14 16 $IRIS2$tailpad [1] 0 $IRIS2$length [1] 2 > stopifnot(length(empty.f) == 3L) > > > dat.f <- read.xport(file="testEmpty.xpt") > dat.f $IRIS1 SEPAL_LE SEPAL_WI PETAL_LE PETAL_WI SPECIES 1 5.1 3.5 1.4 0.2 setosa 2 4.9 3.0 1.4 0.2 setosa $EMPTY data frame with 0 columns and 0 rows $IRIS2 SEPAL_LE SEPAL_WI PETAL_LE PETAL_WI SPECIES 1 4.7 3.2 1.3 0.2 setosa 2 4.6 3.1 1.5 0.2 setosa > stopifnot(length(dat.f)==3) > > > proc.time() user system elapsed 0.220 0.027 0.231