if (FALSE) {
data(mtcars)
mtcars = mtcars %>%
apply_labels(
mpg = "Miles/(US) gallon",
cyl = "Number of cylinders",
disp = "Displacement (cu.in.)",
hp = "Gross horsepower",
drat = "Rear axle ratio",
wt = "Weight (lb/1000)",
qsec = "1/4 mile time",
vs = "Engine",
vs = c("V-engine" = 0,
"Straight engine" = 1),
am = "Transmission",
am = c(automatic = 0,
manual=1),
gear = "Number of forward gears",
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