Mapping Function in R - Unused Argument Error

Hi All,

I am currently trying to use a published script for transforming some data.

In particular, I am trying to use a published script which transforms 3-level survey data (EQ-5D-3L) into 5-level survey data (EQ-5D-5L).

The script is published here, with instructional video too. "Table3v5.csv" and "Table5v5.csv" are both necessary.

https://www.sheffield.ac.uk/nice-dsu/methods-development/mapping-eq-5d-5l-3l.

My question

When I run the script, I get the following error message: "Error in rename(., Output = X_EUUKcopula) :
unused argument (Output = X_EUUKcopula)"

Does anyone know how to fix the notation below such that the error message is resolved?

All help would be really appreciated.

library(here)
library(tidyverse)
library(readxl)

#SETTING WORKING DIRECTORY

here::here("My Working Directory")

#FUNCTIONS THAT RETURN ERROR

df_3 = read.csv(here("Table3v5.csv")) %>% mutate(Domain = str_c(X_Y3_1, X_Y3_2, X_Y3_3, X_Y3_4, X_Y3_5),
                                                 X_age = as.numeric(as.factor(X_age5grp)), X_U5 = round(X_U3UK,10)) %>%
  rename(Output = X_EUUKcopula)   # For mapping from 3L to 5L

df_5 = read.csv(here("Table5v5.csv")) %>% mutate(Domain = str_c(X_Y5_1, X_Y5_2, X_Y5_3, X_Y5_4, X_Y5_5),
                                                 X_age = as.numeric(as.factor(X_age5grp)), X_U5 = round(X_U5UK,10)) %>%
  rename(Output = X_EUUKcopula) # For mapping from 5L to 3L

Your script works fine for me -- no error messages, the specified variable renamed to "Output" in both data frames. Try changing rename to dplyr::rename. If that fixes the problem, then something in your actual code (which I assume is more complex than what you posted here) must be masking the rename function.

1 Like

Hi @prubin.

Thanks a lot for your feedback. In the end, I got it to work. I had conflicting/masking libraries, as you identified.

Thank you

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.