I read a SPSS dataset using R. If I view the dataset, there is text description under the variable names. They should be understood as labels of the variables. But I cannot extract them by using label function. Is there anyway to extract them and define them as the label of the variables?enter image description here
Turns out these texts are stored as the attributes of the dataset. I can extract them using attr function
var.labels <- attr(data, "variable.labels")
Then by the smart answer from R: Assign variable labels of data frame columns, I can assign them as variable labels by
label(data) = as.list(var.labels[match(names(data), names(var.labels))])