haven v1.1.0

0

Monthly downloads

0th

Percentile

by Hadley Wickham

Import and Export 'SPSS', 'Stata' and 'SAS' Files

Import foreign statistical formats into R via the embedded 'ReadStat' C library, <https://github.com/WizardMac/ReadStat>.

Readme

Haven

Travis-CI Build Status AppVeyor Build Status codecov CRAN_Status_Badge

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). write_sas() writes .sas7bdat files.

  • 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 14). write_dta() writes .dta files (versions 8-14).

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")

Functions in haven

Name Description
read_spss Read SPSS (SAV & POR) files. Write SAV files.
read_xpt Read and write SAS transport files
read_dta Read and write Stata DTA files.
read_sas Read and write SAS files.
as_factor Convert input to a factor.
labelled Create a labelled vector.
tagged_na "Tagged" missing values
zap_empty Convert empty strings into missing values.
labelled_spss Labelled vectors for SPSS
print_labels Print the labels of a labelled vector
zap_missing Zap special missings to regular R missings
zap_widths Remove display width attributes
zap_formats Remove format attributes
zap_labels Zap labels
No Results!

Last month downloads

Details

License MIT + file LICENSE
LinkingTo Rcpp
LazyData true
URL http://haven.tidyverse.org, https://github.com/tidyverse/haven, https://github.com/WizardMac/ReadStat
BugReports https://github.com/hadley/haven/issues
VignetteBuilder knitr
SystemRequirements GNU make
RoxygenNote 6.0.1
Encoding UTF-8
NeedsCompilation yes
Packaged 2017-07-08 15:47:00 UTC; hadley
Repository CRAN
Date/Publication 2017-07-09 06:40:47 UTC

Include our badge in your README

[![Rdoc](http://www.rdocumentation.org/badges/version/haven)](http://www.rdocumentation.org/packages/haven)