Argument 2 problem

HI all,

I am a newbie and having this problem:

mcs$maths <- recode(mcs$mths, "1='1. Strongly Disagree';2='2. Disagree';3='3. Agree';4='4.
+ Strongly Agree'")
Error: Argument 2 must be named, not unnamed.
Run `rlang::last_error()` to see where the error occurred.

I'm sure it's something easy, but I can't figure it out. Can anyone help?

you haven't told us which package/library the 'recode' function you are trying to use is from... Can you provide that info ? I will assume you intend the function from dplyr.
An example of the correct syntax follows:

# For character values, recode values with named arguments only. Unmatched
# values are unchanged.
(char_vec <- sample(c("a", "b", "c"), 10, replace = TRUE))
recode(char_vec, a = "Apple")

you can access this example, and in general examples for functions by useing the questionmark and function name in your console. for example


Thanks. I'm not sure what happened but I restarted R Cloud and reinstalled some packages and it's working now. On to other problems!

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.