Error in UseMethod("rename")?

#Hello can someone help me with the error message: Error in UseMethod("rename")? I need to rename three of the variables, do you have any idea what to use instead of "rename"?

Sommerumfrage_Muenchen_2019_Haushalt <- read_csv("R/Quantitative Datenanalyse_SS2021/Sommerumfrage_Muenchen_2019_Haushalt.csv")


myvars <- c("EE_2", "EE_4", "D1")

data_sel <- myvars

data_sel <- rename(data_sel, Nutzungsverständnis = EE_2, Bedienungsverständnis = EE4, Alter = D1)

Error Message:
Fehler in UseMethod("rename") :
nicht anwendbare Methode für 'rename' auf Objekt der Klasse "character" angewendet

Thanks you soooo much :slight_smile:

In your code data_sel is just a character vector containing this values ("EE_2", "EE_4", "D1"), you can't apply the rename function over a character vector, I think this is what you actually want to do


ommerumfrage_Muenchen_2019_Haushalt <- read_csv("R/Quantitative Datenanalyse_SS2021/Sommerumfrage_Muenchen_2019_Haushalt.csv")

data_sel <- ommerumfrage_Muenchen_2019_Haushalt %>% 
    select(EE_2, EE_4, D1) %>% 
    rename(Nutzungsverständnis = EE_2, Bedienungsverständnis = EE4, Alter = D1)


If this doesn't solve your problem, please provide a proper REPRoducible EXample (reprex) illustrating your issue.

This topic was automatically closed 21 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.