Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- library(devtools)
- install_github('NickCH-K/vtable')
- library(vtable)
- #Load in some data
- data("LifeCycleSavings")
- vtable(LifeCycleSavings)
- vtable(LifeCycleSavings,values=TRUE)
- #Values option works with factors too. Set factor.limit to decide how many to show.
- LifeCycleSavings$country <- as.factor(row.names(LifeCycleSavings))
- vtable(LifeCycleSavings,values=TRUE)
- #Create value labels
- #These are nicked from the help(LifeCycleSavings) file
- #but a lot of datasets don't have a file like that!
- labs <- c('numeric aggregate personal savings',
- 'numeric % of population under 15',
- 'numeric % of population over 75',
- 'numeric real per-capita disposable income',
- 'numeric % growth rate of dpi')
- vtable(LifeCycleSavings,labels=labs,values=TRUE,
- data.title="Intercountry Life-Cycle Savings Data",desc="Data on the savings ratio 1960–1970.")
- #These label variants would work just as well:
- #Data frame or matrix where column 1 is variable names and column 2 is labels
- labsv2 <- data.frame(v1=names(LifeCycleSavings),
- v2=c('numeric aggregate personal savings',
- 'numeric % of population under 15',
- 'numeric % of population over 75',
- 'numeric real per-capita disposable income',
- 'numeric % growth rate of dpi'))
- #Data frame or matrix where column titles are variable names and row 1 is labels
- labsv3 <- data.frame(sr="numeric aggregate personal savings",
- pop15='numeric % of population under 15',
- pop75='numeric % of population over 75',
- dpi='numeric real per-capita disposable income',
- ddpi='numeric % growth rate of dpi')
- #This data set has embedded variable labels and value labels
- library(sjlabelled)
- data(efc)
- vtable(efc,values=TRUE)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement