Recode Issues with Unused Argument Error

I am trying to recode a Character vector to have numerical value that can be used in an equation later on. I keep getting the error:

Error in recode(HealthStatus, Green = 90) : unused argument (Green = 90.......)

I currently have:

HealthStatus <- as.matrix(Real_Example_Data[,3])

New_HealthStatus <- recode(HealthStatus, 'Green'= 90, 'UpGreen'= 80, 'Yellow'= 70, 'UpYellow'= 60, 'Orange'= 50, 'UpOrange'= 40, 'Red'= 20)

I have tried multiple ways of using " " or ' ' to see if that changes the error and it doesn't.

Any help with this would be appreciated. The main thing is that I have to be able to use the numeric values later on.

To help us help you, could you please prepare a reproducible example (reprex) illustrating your issue? Please have a look at this guide, to see how to create one:

Status
[1,] "Yellow"
[2,] "Yellow"
[3,] "Yellow"
[4,] "Yellow"
[5,] "Yellow"
[6,] "Yellow"
[7,] "Yellow"
[8,] "UpGreen"
[9,] "UpGreen"
[10,] "UpGreen"
[11,] "UpGreen"
[12,] "UpGreen"
[13,] "UpGreen"
[14,] "UpGreen"
[15,] "UpGreen"
[16,] "Yellow"
[17,] "Yellow"
[18,] "Yellow"
[19,] "Yellow"
[20,] "Yellow"

What is that supposed to be? please read the link I gave you and try to provide a proper reproducible example.
Note: recode() function is not from base R and we can't know from what package is coming from.

Read the documentation https://www.rdocumentation.org/packages/car/versions/3.0-3/topics/recode

You have to provide that argument as a character string e.g."'Green'= 90;'UpGreen'= 80;'Yellow'= 70

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