.packageName <- "foreign"
SModeNames <-
c("name", "string", "literal", "compiled", "(", ")", "[", "]",
"{", "}", ",", "=", "!", ":", "addop", "*/", "<dummy>", "^",
"-", "$", "logop", "&|", "<-", "->", "sp.op", " ", "repeat",
"if", "else", "break", ";", "next", "while", "for", "in", "recursive.return",
"return", "argument", "system", "end.of.file", "expression",
"system.function", "missing", "call", "function", "?", "unbalanced",
"[[", "unknown", "]]", "quit", "continue", "comment.expression",
"vector", "call(...)", "<<-", "graphics", "arg.lvalue", "internal",
"S.call", "S.data", "comment", "comment(leftover)",
"evaluation.frame", "destination")

read.S <- function (file)
{
    endian <- .Platform$endian
    s <- file(file, open = "rb")
    on.exit(close(s))

    readheader <- function(s)
    {
        head <- readBin(s, "int", 8, 1)
        all(head == c(0, 83, 32, 100, 97, 116, 97, 1))
    }

    ReadSObj <- function (code, len)
    {
        if (code == 1)
            result <- as.logical(readBin(s, "int", len, endian = endian))
        else if (code == 2)
            result <- readBin(s, "int", len, endian = endian)
        else if (code == 3)
            result <- readBin(s, "numeric", len, size=4, endian = endian)
        else if (code == 4)
            result <- readBin(s, "numeric", len, endian = endian)
        else if (code == 5) {
            charsize <- readBin(s, "int", endian = endian)
            newpos <- charsize + seek(s, NA)
            result <- readBin(s, "character", len)
            seek(s, newpos)
        }
        else if (code == 6) {
            result <- list()
            if (len > 0) {
                names <- ReadSObj(5, len)
                codes <- ReadSObj(2, len)
                lens <- ReadSObj(2, len)
                offsets <- ReadSObj(2, len)
                for (i in 1:len) {
                    seek(s, offsets[i])
                    if (codes[i] > 0)
                        temp <- ReadSObj(codes[i], lens[i])
                    else
                        temp <- as.name(names[i])
                    if (names[i] != "")
                        result[[names[i]]] <- temp
                    else
                        result[[i]] <- temp
                }
            }
        }
        else if (code == 7)
            result <- readBin(s, "complex", len, endian = endian)
        else if (code == 21) {
            temp <- ReadSObj(6, len)
            result <- temp[[".Data"]]
            attributes(result) <-
                temp[-match(c(".Data", ".Dim", ".Dimnames", ".Label"),
                            names(temp), nomatch = 0)]
            dim(result) <- temp[[".Dim"]]
            names(result) <- names(temp[[".Data"]])
            if (!is.null(temp[[".Label"]]))
                levels(result) <- temp[[".Label"]]
            if (!is.null(temp[[".Dimnames"]]))
                dimnames(result) <- temp[[".Dimnames"]]
        }
        else if (code %in% 257:321) {
            code <- SModeNames[code - 256]
            if (code %in% c("name", "missing"))
                result <- ReadSObj(5, len)
            else
                result <- ReadSObj(6, len)
            if (code == "function")
                try(result <- as.function(result, env=.GlobalEnv))
            else if (code %in% c("break", "if", "for", "return", "S.call",
                                 "while", "<-", "<<-", "(", "{"))
                result <- as.call(c(as.name(code),result))
            else if (code == "call(...)")# these aren't special in R
                result <- result[[1]]
            else if (code == "comment") # ignore comments
                result <- NULL
            else if (code == "comment.expression")# just keep the expression, not the comment
                result <- result[unlist(lapply(result,function(y) !is.null(y)))][[1]]
            else if (code == "internal")
                result <- as.call(list(as.name(".Internal"), result[[1]]))
            else if (code == "missing")
                result <- call("stop", "Argument is missing")
            else try(mode(result) <- code)
        }
        else {
            return(paste("Unrecognized S mode", code, "not supported"))
        }
        result
    }
    if(readheader(s)) {
        code <- readBin(s, "int", endian = endian)
        if (code < 0 | code > 65535) {
            endian <- switch(endian, big = "little", little = "big")
            seek(s,  seek(s, NA) -4)
            code <- readBin(s, "int", endian = endian)
            if (code < 0 | code > 65535)
                stop("Internal error - illegal S code value\n")
        }
        len <- readBin(s, "int", endian = endian)
        return(ReadSObj(code, len))
    }
    else stop("not an S object")
}

data.restore <-
    function (file, print = FALSE, verbose = FALSE, env = .GlobalEnv)
{
    dump <- file(file, open="rt")
    on.exit(close(dump))

    ReadSdump <- function(top = FALSE, prefix) {
        name <- readLines(dump, 1)
        if(length(name) == 0) return(NULL)
        code <- readLines(dump, 1)
        len <- as.integer(readLines(dump, 1))
        if (top && print)
            cat("\"", name, "\": ", code, "\n", sep="")
        if (verbose)
            cat(prefix, summary(dump)$position, name, code, len, "\n")
        if (code == "logical") {
            value <- as.logical(readLines(dump, len))
        }
        else if (code %in% c("numeric","integer","single")) {
            value <- as.numeric(readLines(dump, len))
        }
        else if (code %in% c("character", "name", "missing")) {
            value <- readLines(dump, len)
            if (code == "name") {
                value <- as.name(value)
            }
            if (code == "missing") {    ## Workaround:  should be value <- as.name("")
                value <- call("stop",
                              paste("Argument `", name, "' is missing", sep=""))
            }
        }
        else if (code == "complex") {
            value <- as.complex(readLines(dump, len))
        }
        else if (code %in% c("list", "structure", "NULL", SModeNames)) {
            value <- list()
            if (len > 0) {
            	for (i in 1:len) {
                    temp <- ReadSdump(FALSE, c(prefix, " "))
                    if (temp$name != "")
                    	value[[temp$name]] <- temp$value
                    else value[[i]] <- temp$value
                }
            }
            if (code == "structure") {
                thelist <- value
                value <- thelist[[".Data"]]
                attributes(value) <-
                    thelist[-match(c(".Data", ".Dim", ".Dimnames", ".Label"),
                                   names(thelist), nomatch = 0)]
                dim(value) <- thelist[[".Dim"]]
                names(value) <- names(thelist[[".Data"]])
                if (!is.null(thelist[[".Label"]]))
                    levels(value) <- thelist[[".Label"]]
                if (!is.null(thelist[[".Dimnames"]]))
                    try(dimnames(value) <- thelist[[".Dimnames"]])
            }
            else if (code == "function")
                try(value <- as.function(value,env=env))
            else if (code %in% c("break", "if", "for", "return", "S.call",
                                 "while", "<-", "<<-", "(", "{"))
                value <- as.call(c(as.name(code), value))
            else if (code == "NULL") {
				if (name == "") value <- NULL
				else value <- as.name(name)
			}
            else if (code == "call(...)")# these aren't special in R
                value <- value[[1]]
            else if (code == "comment") # ignore comments
                value <- NULL
            else if (code == "comment.expression")# just keep the expression, not the comment
                value <- value[unlist(lapply(value,function(y) !is.null(y)))][[1]]
            else if (code == "internal")
                value <- as.call(list(as.name(".Internal"),value[[1]]))

            else try(mode(value) <- code)
        }
        else {
            stop(paste("S mode \"", code, "\" (near byte offset ",
                       seek(dump), ") not supported", sep = ""))
        }
        list(name = name, value = value)
    }
    repeat {
        temp <- ReadSdump(TRUE, " ")
        if(is.null(temp)) break
        assign(temp$name, temp$value, env = env)
    }
    file
}
### $Id: minitab.R,v 1.2 2001/06/09 14:40:20 hornik Exp $
###
###             Read stored Minitab worksheets
###
### Copyright 1999-2000 Douglas M. Bates <bates$stat.wisc.edu>,
###                     Saikat DebRoy <saikat$stat.wisc.edu>
###
### This file is part of the `foreign' library for R and related languages.
### It is made available under the terms of the GNU General Public
### License, version 2, or at your option, any later version,
### incorporated herein by reference.
###
### This program is distributed in the hope that it will be
### useful, but WITHOUT ANY WARRANTY; without even the implied
### warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
### PURPOSE.  See the GNU General Public License for more
### details.
###
### You should have received a copy of the GNU General Public
### License along with this program; if not, write to the Free
### Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
### MA 02111-1307, USA

## Files in the Minitab portable worksheet format represent numbers in a
## fixed format (written in Fortran as 5e15.9 or something like that) but
## the data values are only stored in Minitab in single precision.  We use
## signif to remove the inaccuracies in the representation in the files.

"read.mtp" <-
function (file) {
    clean <- function(x) if(is.numeric(x)) signif(x, 6) else x
    val <- .Call("read_mtp", file, PACKAGE = "foreign")
    lapply(val, clean)
}

read.dta <- function(file, convert.dates=TRUE,tz="GMT",
                      convert.factors=TRUE,missing.type=FALSE,
                     convert.underscore=TRUE){
    rval<-.External("do_readStata", file,  PACKAGE = "foreign")

    if(convert.underscore)
      names(rval)<-gsub("_",".",names(rval))

    types<-attr(rval,"types")    
    stata.na<-data.frame(type=251:255,
                         min=c(101, 32741, 2147483621, 2^127, 2^1023),
                         inc=c(1,1,1,2^115,2^1011)
                         )

         
    if(!missing.type){
        if (abs(attr(rval,"version"))==8){
            for(v in which(types>250)){
                this.type<-types[v]-250
                rval[,v][rval[,v]>=stata.na$min[this.type]]<-NA
            }
        }
    } else {
        if (abs(attr(rval,"version"))==8){
            missings<-vector("list",NCOL(rval))
            names(missings)<-names(rval)
            for(v in which(types>250)){
                this.type<-types[v]-250
                nas<-is.na(rval[,v]) |  rval[,v]>=stata.na$min[this.type]
                natype<-(rval[nas,v]-stata.na$min[this.type])/stata.na$inc[this.type]
                natype[is.na(natype)]<-0
                missings[[v]]<-rep(NA,NROW(rval))
                missings[[v]][nas]<-natype
                rval[nas,v]<-NA
            }
            attr(rval,"missing")<-missings
        } else {
            warning("`missing.type' only applicable to version 8 files")
        }
        
    }

    if (convert.dates){
        ff<-attr(rval,"formats")
        dates<-grep("%-*d",ff)
        for(v in dates)
            rval[[v]]<-ISOdate(1960,1,1,tz=tz)+24*60*60*rval[[v]]
    }
    if (convert.factors){
        if (attr(rval, "version")==5)
          warning("Can't read factor labels from Stata 5 files.")
        else {
          ll<-attr(rval,"val.labels")
          tt<-attr(rval,"label.table") 
          factors<-which(ll!="")
          for(v in factors){
            labels<-tt[[ll[v]]]
            if (is.null(labels)){
              warning("Value labels (",ll[v],") for ",names(rval)[v]," are missing")
              next
            }
            rval[[v]]<-factor(rval[[v]],levels=tt[[ll[v]]],labels=names(tt[[ll[v]]]))
          }
        }
      }
    

    rval
    
  }

write.dta <- function(dataframe, file, version = 6,convert.dates=TRUE,tz="GMT",
                      convert.factors=c("labels","string","numeric","codes"))
{

    if (version<6) stop("Version must be 6-8")
    if (version>8) {
        warning("Version must be 6-8: using 7")
        version<-7
    }
        

    
    namelength<-if (version==6) 8 else 31
    oldn<-names(dataframe)
    nn<-abbreviate(oldn,namelength )
    if (any(nchar(nn)>namelength))
        stop("Can't uniquely abbreviate variable names")
    if (any(nchar(oldn)>namelength))
        warning("Abbreviating variable names")
    names(dataframe)<-nn
    attr(dataframe,"orig.names")<-oldn
    
    if (convert.dates){
        dates<-which(isdate<-sapply(dataframe,function(x) inherits(x,"POSIXt")))
        for( v in dates)
            dataframe[[v]]<-as.vector(round(julian(dataframe[[v]],ISOdate(1960,1,1,tz=tz))))
    }
    convert.factors<-match.arg(convert.factors)
    factors<-which(sapply(dataframe,is.factor))
    if(convert.factors=="string"){
        for(v in factors)
            dataframe[[v]]<-I(as.character(dataframe[[v]]))
    } else if (convert.factors=="numeric"){
         for(v in factors)
             dataframe[[v]]<-as.numeric(as.character(dataframe[[v]]))
     } else if (convert.factors=="codes"){
         for (v in factors)
             dataframe[[v]]<-as.numeric(dataframe[[v]])
     }

    shortlevels<-function(f){
        ll<-levels(f)
        if (is.null(ll))
            return(NULL)
        abbreviate(ll,80)}


    leveltable<-lapply(dataframe,shortlevels)
     
    if (any(sapply(dataframe, function(x) !is.null(dim(x)))))
        stop("Can't handle multicolumn columns")
    invisible(.External("do_writeStata", file, dataframe, version, leveltable, 
                        PACKAGE = "foreign"))
}
read.epiinfo <- function (file, read.deleted = FALSE, guess.broken.dates = FALSE, thisyear = NULL, lower.case.names = FALSE) 
  {
    if (is.character(file)) {
        file <- file(file, "rt")
        on.exit(close(file))
    }
    if (!inherits(file, "connection")) 
        stop("argument 'file' must be a character string or connection")
    if (!isOpen(file)) {
        open(file, "rt")
        on.exit(close(file))
    }
    line <- readLines(file, 1, ok = TRUE)
    headerlength <- na.omit(sapply(strsplit(line, " ")[[1]], as.numeric))[1]
    if (headerlength <= 0) 
        stop(paste("file has zero or fewer variables: probably not an EpiInfo file"))
    headerlines <- readLines(file, n = headerlength)
    pushBack(headerlines, file)
    comments <- sapply(headerlines, function(s) substring(s, 46, 46 + 80))
    #
    # Added comment = ""  to fix '#' as entrychar being read as a comment
    #        
    header <- scan(file, nlines = headerlength, what = list(name = "", x = 0, y = 0, color = 0, x1 = 0, y1 = 0, type = 0, len = 0, color = 0), flush = TRUE, quiet = TRUE, comment = "")
    header <- as.data.frame(lapply(header, I))
    header$start <- cumsum(c(1, header$len))[1:headerlength]
    header$stop <- cumsum(header$len)
    multiline <- ceiling(max(header$stop) / 78)
    really.variables <- header$len != 0
    header <- header[really.variables, ]
    entrychar <- substr(header$name, 1, 1)
    if (all(entrychar %in% c("#", "_"))) 
        header$name <- substr(header$name, 2, 12)
    comments <- comments[really.variables]
    #
    # Added support for EpiData introduced field types:
    #
    #   12  Automatic ID number fields (treated as numeric)
    #   16  European (i.e. dd/mm/yyyy) format automatic date    
    #   17  SOUNDEX field
    #
    numbers <- (header$len > 0) & ((header$type %in% c(0, 6, 12)) | (header$type > 12)) & !(header$type %in% c(16, 17))  
    datalines <- scan(file, what = "", sep = "\n", quote = "", quiet = TRUE, blank.lines.skip = TRUE, comment = "")
    #
    # Added check for empty file
    #                                          
    if (length(datalines) == 0)
      stop("no records in file")
    if (length(datalines)%%multiline) 
        warning("wrong number of records")
    datalines <- matrix(datalines, nrow = multiline)
    if (multiline > 1) 
        datalines[-multiline, ] <- substr(datalines[-multiline, ], 1, 78)
    datalines <- apply(datalines, 2, paste, collapse = "")
    deleted <- substr(datalines, nchar(datalines), nchar(datalines)) == "?"
    nvars <- NROW(header)
    data <- as.data.frame(lapply(1:nvars, function(i) I(substring(datalines, header$start[i], header$stop[i]))))
    names(data) <- header$name
    names(comments) <- header$name
    if (is.na(read.deleted)) 
        data[deleted, ] <- NA
    else if (!read.deleted) 
        data <- data[!deleted, ]
    if (guess.broken.dates && is.null(thisyear)) 
        thisyear <- format(Sys.time(), format = "%Y")
    #
    # Added support for field types:
    #
    #   10  US (i.e. mm/dd/yyyy) format field (EpiInfo)
    #   12  Automatic ID number (treated as numeric)
    #   16  European (i.e. dd/mm/yyyy) format automatic date (EpiData)
    #   17  SOUNDEX field (EpiData)
    #   
    for (i in 1:nvars) {
        if (numbers[i]) 
            data[[i]] <- as.numeric(data[[i]])
        else if (header$type[i] == 5) 
            data[[i]] <- ifelse(data[[i]] %in% c("Y", "N"), data[[i]] == "Y", NA)
        else if (header$type[i] %in% c(11, 16) && header$len[i] == 5 && guess.broken.dates) 
            data[[i]] <- as.POSIXct(strptime(paste(data[[i]], thisyear, sep = "/"), format = "%d/%m/%Y"))
        else if (header$type[i] %in% c(11, 16) && header$len[i] == 8 && guess.broken.dates) 
            data[[i]] <- as.POSIXct(strptime(data[[i]], format = "%d/%m/%y"))
        else if (header$type[i] %in% c(11, 16) && header$len[i] == 10) 
            data[[i]] <- as.POSIXct(strptime(data[[i]], format = "%d/%m/%Y"))
        else if (header$type[i] %in% c(2, 10) && header$len[i] == 5 && guess.broken.dates) 
            data[[i]] <- as.POSIXct(strptime(paste(data[[i]], thisyear, sep = "/"), format = "%m/%d/%Y"))
        else if (header$type[i] %in% c(2, 10) && header$len[i] == 8 && guess.broken.dates) 
            data[[i]] <- as.POSIXct(strptime(data[[i]], format = "%d/%m/%y"))
        else if (header$type[i] %in% c(2, 10) && header$len[i] == 10) 
            data[[i]] <- as.POSIXct(strptime(data[[i]], format = "%d/%m/%Y"))
        #
        # SOUNDEX (type 17) fields
        #            
        else if (header$type[i] == 17) {
            data[[i]][substr(data[[i]], 1, 1) == " "] <- NA
            data[[i]] <- substr(data[[i]], 1, 5)
            }
        else {
            blanks <- grep("^[ \\t]*$", data[[i]])
            data[[i]][blanks] <- NA
        }
    }
    if (!is.na(read.deleted) && read.deleted) 
        attr(data, "deleted") <- deleted
    attr(data, "prompts") <- comments
    #
    # Added parameter and code to specify lower case variable names
    #
    if (lower.case.names)
      names(data) <- tolower(names(data))
    data
  }

read.ssd <- function(libname, sectionnames, tmpXport=tempfile(),
                     tmpProgLoc=tempfile(), sascmd="sas")
{
    ##
    ## copyright 2002 VJ Carey <stvjc@channing.harvard.edu>
    ##
    ## read.ssd -- 'read' a SAS v6 ssd format file by converting
    ## the data to sas xport format and then using R foreign:read.xport
    ## march 22 2002 -- works fine if the desired sas lib/section exist
    ## but cannot detect when sas 'fails' owing to nonexistence
    ##
    ## tries to clean up interim results
    ##
    ## works for sas v8
    ##
    ## require(foreign)
    on.exit(unlink(tmpXport))
    logGuess <- function (x)
    {
        ## guess the name of the log file by stripping all
        ## path to the sas program (log will lie in executing dir)
        expl <- strsplit(x, "")[[1]]
        rex <- rev(expl)
        br <- match("/", rex)[1]
        if (is.na(br))
            return(x)
        return(paste(rev(rex[1:(br - 1)]), sep = "", collapse = ""))
    }
    st1 <- paste("libname src2rd '",libname,"';\n",sep="")
    st2 <- paste("libname rd xport '", tmpXport, "';\n", sep="")
    st3 <- paste("proc copy in=src2rd out=rd;\n")
    st4 <- paste("select", sectionnames, ";\n", sep=" ")
    tmpProg <- paste(tmpProgLoc, ".sas", sep="")
    tmpProgLogBase <- logGuess(tmpProgLoc)
    tmpProgLog <- paste(tmpProgLogBase, ".log", sep="")
    cat(st1, file=tmpProg)
    cat(st2, file=tmpProg, append=TRUE)
    cat(st3, file=tmpProg, append=TRUE)
    cat(st4, file=tmpProg, append=TRUE)
    sasrun <- try(sysret <- system( paste( sascmd, tmpProg ) ))
    if (!inherits(sasrun, "try-error") & sysret == 0)
    {
        unlink( tmpProg )
        unlink( tmpProgLog )
        return( read.xport( tmpXport ) )
    }
    else
    {
        cat("SAS failed.  SAS program at", tmpProg,"\n")
        cat("a log and other error products should be in the vicinity\n")
        system(paste("ls -l ", tmpProgLog))
        warning(paste("SAS return code was", sysret))
        return(NULL)
    }
}
### $Id: spss.R,v 1.5 2002/04/29 19:48:37 saikat Exp $
###
###             Read SPSS system data files
###
### Copyright 2000-2002 Saikat DebRoy <saikat$stat.wisc.edu>
###                     Douglas M. Bates <bates$stat.wisc.edu>,
###                     Thomas Lumley
### This file is part of the `foreign' library for R and related languages.
### It is made available under the terms of the GNU General Public
### License, version 2, or at your option, any later version,
### incorporated herein by reference.
### 
### This program is distributed in the hope that it will be
### useful, but WITHOUT ANY WARRANTY; without even the implied
### warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
### PURPOSE.  See the GNU General Public License for more
### details.
### 
### You should have received a copy of the GNU General Public
### License along with this program; if not, write to the Free
### Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
### MA 02111-1307, USA

read.spss <- function(file,use.value.labels=TRUE,to.data.frame=FALSE,
                      max.value.labels=Inf) {
    rval<-.Call("do_read_SPSS", file, PACKAGE = "foreign")
    
    if (use.value.labels){
      vl<-attr(rval,"label.table")
      has.vl<-which(!sapply(vl,is.null))
      for(v in has.vl){
        nm<-names(vl)[[v]]
        if (!is.finite(max.value.labels) || length(unique(rval[[nm]]))<=max.value.labels)
            rval[[nm]]<-factor(rval[[nm]],levels=vl[[v]],labels=names(vl[[v]]))
        else
            attr(rval[[nm]],"value.labels")<-vl[[v]]
      }
    }
    
    if (to.data.frame) {
      varlab <- attr(rval, "variable.labels")
      rval <- as.data.frame(rval)
      attr(rval, "variable.labels") <- varlab
    }
    rval
}
### $Id: xport.R,v 1.2 2001/06/09 14:40:20 hornik Exp $
###
###             Read SAS xport format libraries
###
### Copyright 1999-1999 Douglas M. Bates <bates$stat.wisc.edu>,
###                     Saikat DebRoy <saikat$stat.wisc.edu>
###
### This file is part of the `foreign' library for R and related languages.
### It is made available under the terms of the GNU General Public
### License, version 2, or at your option, any later version,
### incorporated herein by reference.
### 
### This program is distributed in the hope that it will be
### useful, but WITHOUT ANY WARRANTY; without even the implied
### warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
### PURPOSE.  See the GNU General Public License for more
### details.
### 
### You should have received a copy of the GNU General Public
### License along with this program; if not, write to the Free
### Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
### MA 02111-1307, USA

lookup.xport <- function(file) {
    .Call("xport_info", file, PACKAGE = "foreign")
}

read.xport <- function(file) {
    data.info <- lookup.xport(file)
    ans <- .Call("xport_read", file, data.info, PACKAGE = "foreign")
    if (length(ans) == 1)
        as.data.frame(ans[[1]])
    else lapply(ans, as.data.frame)
}
### $Id: zzz.R,v 1.3 2003/12/20 09:05:09 ripley Exp $
###
###             Read stored Minitab worksheets
###
### Copyright 1999-1999 Douglas M. Bates <bates$stat.wisc.edu>,
###                     Saikat DebRoy <saikat$stat.wisc.edu>
###
### This file is part of the `foreign' library for R and related languages.
### It is made available under the terms of the GNU General Public
### License, version 2, or at your option, any later version,
### incorporated herein by reference.
###
### This program is distributed in the hope that it will be
### useful, but WITHOUT ANY WARRANTY; without even the implied
### warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
### PURPOSE.  See the GNU General Public License for more
### details.
###
### You should have received a copy of the GNU General Public
### License along with this program; if not, write to the Free
### Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
### MA 02111-1307, USA

.onLoad <- .First.lib <- function(lib, pkg) {
    library.dynam("foreign", pkg, lib)
    .C("spss_init", PACKAGE = "foreign")
}
