suppress the 'labelled' from class()

This is with regard to the dataframe 'have' as created below, in this i derived a variable name with a label. so i get the have dataframe with variable name and a label. when i check the class of the variable in the have dataframe i also see the 'labelled' which i dont want to see i only want see the 'character', so please let me know is there a way i apply the label as well but when i use the class then i see only see 'character'

# creating a data frame have
have <- data.frame(name=c('person1','person2','person3','person4'))
# applying a label to the data frame
label(have$name) <- 'Name of person'
# checking the class of the variable within the dataframe



if you don't like how label works then don't use it and solve your issue by another approach, but its not at all clear that you have any concrete problem needing a solution.

My gut is telling me that you are worried about this because you may have adopted some pattern like checking if class(x) == 'character', if that is the case, you should avoid doing such class checking
is.character(x) will report easily if character is one of the class settings of x, and solves the identification problem while allowing x to have multiple classes.

Thank you for the response. however for my requirement I need the class to show only one attribute i.e., 'numeric'.

This is possible by the labelled package var_label().

labelled::var_label(have$name) <- 'Name of person'

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.