answer <- sample(c(1,2,3,8,9),size=30,replace=TRUE)
labels(answer) <- c(Conservatives = 1,
Labour = 2,
"Liberal Democrats" = 3,
"Don't know" = 8,
"Answer refused" = 9
)
missing.values(answer) <- c(8,9)
as.data.frame(answer)[[1]]
measurement(answer) <- "interval"
as.data.frame(answer)[[1]]
Run the code above in your browser using DataLab