I have two data frames (regionSum
and areaSum
) shown below.
Area | Region | void_pts |
---|---|---|
0 | 010 | 0.125 |
1 | 110 | 1.566 |
1 | 111 | 1.350 |
3 | 310 | 2.004 |
3 | 312 | 1.652 |
Area | void_pts |
---|---|
0 | 0.455 |
1 | 1.436 |
2 | 1.396 |
3 | 1.981 |
I'm trying to create a new column (alert
) in the regionSum
dataframe using these two conditions: regionSum$void_pts >= areaSum$void_pts
and regionSum$area == areaSum$area
.
Here is a snippet of the code that I've tried to use but its errors out.
t %>%
mutate(alert = case_when(void_pts >= areaSum$void_pts & area == areaSum$area ~ "Red",
TRUE ~ "Blue" )
What am I missing to give me the below results and how'd I go by tackling the same problem in the case of a lot of factors of the area
field?
Area | Region | void_pts | alert |
---|---|---|---|
0 | 010 | 0.125 | blue |
1 | 110 | 1.566 | red |
1 | 111 | 1.350 | blue |
3 | 310 | 2.004 | red |
3 | 312 | 1.652 | blue |