File: R_systat.R

package info (click to toggle)
foreign 0.8.40-1
  • links: PTS
  • area: main
  • in suites: squeeze
  • size: 1,576 kB
  • ctags: 657
  • sloc: ansic: 6,997; asm: 4; sh: 2; makefile: 1
file content (33 lines) | stat: -rw-r--r-- 1,190 bytes parent folder | download | duplicates (2)
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
### This file is part of the 'foreign' package for R.

# Copyright 2004 by Roger Bivand
#
#  This program is free software; you can redistribute it and/or modify
#  it under the terms of the GNU General Public License as published by
#  the Free Software Foundation; either version 2 of the License, or
#  (at your option) any later version.
#
#  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.
#
#  A copy of the GNU General Public License is available at
#  http://www.r-project.org/Licenses/
#

read.systat <- function(file, to.data.frame=TRUE)
{
    if (length(file) != 1L) stop("only one file")
    if (!is.character(file)) stop("file must be character")
    res <- .Call(readSystat, as.character(file))
    if (to.data.frame) {
        comment <- NULL
        if (!is.null(attr(res, "comment")) &&
            nzchar(attr(res, "comment")))
            comment <- attr(res, "comment")
        res <- as.data.frame(res)
        if (!is.null(comment)) comment(res) <- comment
    }
    res
}