tests/testEmpty.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
stopifnot(length(empty.f) == 3L)


dat.f <- read.xport(file="testEmpty.xpt")
dat.f
stopifnot(length(dat.f)==3)

Try the foreign package in your browser

Any scripts or data that you put into this service are public.

foreign documentation built on June 26, 2024, 9:06 a.m.