Skip to content

Instantly share code, notes, and snippets.

View ajhmohr's full-sized avatar

Alicia Hofelich Mohr ajhmohr

  • University of Minnesota
View GitHub Profile
@mbacou
mbacou / snippets.R
Last active May 2, 2024 22:34
How to read and write STATA variable and value labels from R.
# Using read.dta() to load a sample STATA data file
dta <- read.dta("my_toy_data.dta")
# Let's describe dta
str(dta)
#'data.frame': 95202 obs. of 13 variables:
# $ hh : num 1.01e+09 1.01e+09 1.01e+09 1.01e+09 1.01e+09 ...
#$ h14aq2 : Factor w/ 61 levels "matooke","matooke",..: 50 51 34 47 57 41 22 1 13 53 ...
#$ h14aq3 : Factor w/ 93 levels "Kilogram (kg)",..: 51 26 85 1 NA 1 55 70 1 33 ...
#$ h14aq4 : num 0.5 4 4 1 NA 1.5 5 3 4 10 ...