knitr::opts_chunk$set( collapse = TRUE, comment = "#>", fig.path = "README-" )
meda
This package provides R functions that replicates the behavior of four Stata commands: (1) d
, (2) lookfor
, (3) codebook, compact
, and (4) l, sepby()
. These commands present metadata records for datasets in a cleaned way.
The package is built upon two R packages: haven
, which provides a labelled class that supports labelled data frames, and labelled
, which makes it easier to work with
labelled data frames.
Since the labelled
package is still not up on CRAN, we might also install it as well.
devtools::install_github("larmarange/labelled") devtools::install_github("jjchern/meda")
library(meda) nlsw88 = haven::read_dta("http://www.stata-press.com/data/r13/nlsw88.dta") cb(nlsw88) # show summary statistics of a data frame d(nlsw88) # shows variable labels, and whether value label exists for certain variables # Note that there's a value label for the variable "race", thus we can checkout the values labelled::val_labels(nlsw88$race) # Note also that if a variable label is too long, we can find out the whole label with labelled::var_label(nlsw88$grade) # Or look at all the variable labels labelled::var_label(nlsw88) lookfor(nlsw88, "mar") # search for variables that are related to marriage
library(dplyr) abdata = haven::read_dta("http://www.stata-press.com/data/r13/abdata.dta") abdata %>% select(id, year, wage) %>% l(by = "id", n = 30)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.