haven

Read SPSS, Stata and SAS files from R

  • 所有者: tidyverse/haven
  • 平台:
  • 許可證: Other
  • 分類:
  • 主題:
  • 喜歡:
    0
      比較:

Github星跟蹤圖

haven

CRAN
status
Travis build
status
AppVeyor build
status
Codecov test
coverage

Overview

Haven enables R to read and write various data formats used by other
statistical packages by wrapping the fantastic
ReadStat C library written by
Evan Miller. Haven is part of the
tidyverse. Currently it supports:

  • SAS: read_sas() reads .sas7bdat + .sas7bcat files and
    read_xpt() reads SAS transport files (version 5 and version 8).

  • SPSS: read_sav() reads .sav files and read_por() reads the
    older .por files. write_sav() writes .sav files.

  • Stata: read_dta() reads .dta files (up to version 15).
    write_dta() writes .dta files (versions 8-15).

The output objects:

  • Are tibbles, which have a better
    print method for very long and very wide files.

  • Translate value labels into a new labelled() class, which
    preserves the original semantics and can easily be coerced to
    factors with as_factor(). Special missing values are preserved.
    See vignette("semantics") for more details.

  • Dates and times are converted to R date/time classes. Character
    vectors are not converted to factors.

Installation

# The easiest way to get haven is to install the whole tidyverse:
install.packages("tidyverse")

# Alternatively, install just haven:
install.packages("haven")

# Or the the development version from GitHub:
# install.packages("devtools")
devtools::install_github("tidyverse/haven")

Usage

library(haven)

# SAS
read_sas("mtcars.sas7bdat")
write_sas(mtcars, "mtcars.sas7bdat")

# SPSS
read_sav("mtcars.sav")
write_sav(mtcars, "mtcars.sav")

# Stata
read_dta("mtcars.dta")
write_dta(mtcars, "mtcars.dta")
  • foreign reads from SAS
    XPORT, SPSS, and Stata (up to version 12) files.

  • readstat13 reads
    from and writes to all Stata file format versions.

  • sas7bdat reads from
    SAS7BDAT files.

Code of Conduct

Please note that the haven project is released with a Contributor Code of Conduct. By contributing to this project, you agree to abide by its terms.

主要指標

概覽
名稱與所有者tidyverse/haven
主編程語言C
編程語言R (語言數: 5)
平台
許可證Other
所有者活动
創建於2015-02-04 16:28:17
推送於2025-05-30 14:18:17
最后一次提交
發布數24
最新版本名稱v2.5.5 (發布於 )
第一版名稱v0.1.0 (發布於 )
用户参与
星數442
關注者數21
派生數115
提交數832
已啟用問題?
問題數637
打開的問題數59
拉請求數110
打開的拉請求數3
關閉的拉請求數30
项目设置
已啟用Wiki?
已存檔?
是復刻?
已鎖定?
是鏡像?
是私有?