# NOT RUN {
# from foreign
library(foreign)
df <- to_labelled(read.spss(
'file.sav',
to.data.frame = FALSE,
use.value.labels = FALSE,
use.missings = FALSE
))
df <- to_labelled(read.dta(
'file.dta',
convert.factors = FALSE
))
# from memisc
library(memisc)
nes1948.por <- UnZip('anes/NES1948.ZIP', 'NES1948.POR', package='memisc')
nes1948 <- spss.portable.file(nes1948.por)
df <- to_labelled(nes1948)
ds <- as.data.set(nes19480)
df <- to_labelled(ds)
# }
# NOT RUN {
# Converting factors to labelled vectors
f <- factor(c("yes", "yes", "no", "no", "don't know", "no", "yes", "don't know"))
to_labelled(f)
to_labelled(f, c("yes" = 1, "no" = 2, "don't know" = 9))
to_labelled(f, c("yes" = 1, "no" = 2))
to_labelled(f, c("yes" = "Y", "no" = "N", "don't know" = "DK"))
s1 <- labelled(c('M', 'M', 'F'), c(Male = 'M', Female = 'F'))
labels <- val_labels(s1)
f1 <- to_factor(s1)
f1
to_labelled(f1)
identical(s1, to_labelled(f1))
to_labelled(f1, labels)
identical(s1, to_labelled(f1, labels))
# }
Run the code above in your browser using DataLab