I have created this representative data frame that assigns condition categories using a for loop.
df <- data.frame(Date=c(\"08/29/2011\", \"08/29/2011\", \"
You could use case_when
from dplyr
:
df1<- df %>%
mutate(Accuracy= case_when(
.$Diff <= 3 ~ "Excellent",
.$Diff <= 10 ~ "Good",
.$Diff <= 15 ~ "Fair",
.$Diff <= 30 ~ "Poor",
.$Diff > 30 ~ "Unpublishable",
TRUE ~"TBD")
)
df1
Date Time Diff Accuracy
1 08/29/2011 09:45 0.2 Excellent
2 08/29/2011 10:00 4.3 Good
3 08/30/2011 13:00 6.5 Good
4 08/30/2011 13:30 15.0 Fair
5 08/30/2011 10:14 16.5 Poor
6 08/29/2012 9:09 31.0 Unpublishable
7 08/29/2012 11:23 30.2 Unpublishable
8 01/15/2012 17:06 21.9 Poor
9 08/29/2012 12:20 1.9 Excellent