I am following this: Plot with conditional colors based on values in R
I have the following code:
stripchart(round(df$pnl_act / round_to, 0) * round_to,
xlim=c(-2500,2500),
pch = 20,
method = "stack",
xaxt = "n",
main = paste("Act", pp1[[1]], pp2[[1]], pp3[[1]],threshold_vector[1], sep = "-"),
col = ifelse((round(df$pnl_act / round_to, 0) * round_to) > 0, "red", "green")
)
However, all my colors are green.
When I run this:
(round(df$pnl_act / round_to, 0) * round_to) > 0
I get:
[1] FALSE FALSE FALSE FALSE TRUE FALSE TRUE TRUE TRUE TRUE FALSE FALSE TRUE TRUE FALSE FALSE FALSE TRUE FALSE
[20] FALSE
Any ideas where I went wrong?
Edit:
Here is the vector of data:
df$pnl_act
Output:
[1] 0 -220 -270 -50 190 -210 90 170 50 60 -390 -50 40 410 -10 -180 -170 230 -100 -1000