# NOT RUN {
data(mtcars)
mtcars = modify(mtcars,{
var_lab(mpg) = "Miles/(US) gallon"
var_lab(cyl) = "Number of cylinders"
var_lab(disp) = "Displacement (cu.in.)"
var_lab(hp) = "Gross horsepower"
var_lab(drat) = "Rear axle ratio"
var_lab(wt) = "Weight (lb/1000)"
var_lab(qsec) = "1/4 mile time"
var_lab(vs) = "Engine"
val_lab(vs) = c("V-engine" = 0,
"Straight engine" = 1)
var_lab(am) = "Transmission"
val_lab(am) = c(automatic = 0,
manual=1)
var_lab(gear) = "Number of forward gears"
var_lab(carb) = "Number of carburetors"
})
write_labelled_csv(mtcars, "mtcars.csv")
new_mtcars = read_labelled_csv("mtcars.csv")
str(new_mtcars)
# identically, for xlsx
write_labelled_xlsx(mtcars, "mtcars.xlsx")
new_mtcars = read_labelled_xlsx("mtcars.xlsx")
str(new_mtcars)
# to SPSS syntax
write_labelled_spss(mtcars, "mtcars.csv")
# }
Run the code above in your browser using DataLab