1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163
|
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
|