rimportspss

Get the sub colnames of a dataframe from SPSS to R (read.spss)


i'm new to stack overflow, i have a question.

When i import a dataframe from spss to R with the function read.spss it appears in the colnames two elements: the name of the column and a "sub name" of the column like in the image below:

image in Rstudio

This "sub-colnames" refers to the column Label in SPSS (variable View) like in the image below: enter image description here

My question is: Is there a function that can tell me in the console all the sub-colnames like with the function colnames(dataframe) ? Also, this function could tell me the colname and the subcolname of each column at the same time?

Thanks


Solution

  • According to help(read.spss) the attribute variable.labels has the columns labels

    df <- read.spss("file")
    attr(df, "variable.labels")