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 repr oducible ex ample (reprex) illustrating your issue? Please have a look at this guide, to see how to create one:
A minimal reproducible example consists of the following items:
A minimal dataset, necessary to reproduce the issue
The minimal runnable code necessary to reproduce the issue, which can be run
on the given dataset, and including the necessary information on the used packages.
Let's quickly go over each one of these with examples:
Minimal Dataset (Sample Data)
You need to provide a data frame that is small enough to be (reasonably) pasted on a post, but big enough to reproduce your issue.
Let's say, as an example, that you are working with the iris data frame
head(iris)
#> Sepal.Length Sepal.Width Petal.Length Petal.Width Species
#> 1 5.1 3.5 1.4 0.…
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
system
Closed
August 13, 2019, 4:51pm
7
This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.