Я бы использовал точечную диаграмму для построения различий:
ИЛЛЮСТРАТИВНЫЕ ДАННЫЕ :
set.seed(122)
df <- data.frame(
id = 1:10,
exp = sample(1000:5000, 10),
curr = sample(800: 4500, 10)
)
РЕШЕНИЕ :
Рассчитать разницу:
df$diff <- df$curr - df$exp
Рисовать точечную диаграмму:
dotchart(df$diff, labels = df$id, main = "Difference in current v expected income",
col = ifelse(df$diff < 0, "red", "blue"), density = 50, angle = 90)
abline(v = 0)
РЕЗУЛЬТАТ :
(очевидно, это может быть очень приукрашено) ![enter image description here](https://i.stack.imgur.com/kJtSw.png)
РЕДАКТИРОВАТЬ :
Как насчет использования барплота?
barplot(df$diff, names = df$id, xlab = "ID", ylab = "Difference",
main = "Difference in current v expected income",
col = ifelse(df$diff < 0, "red", "blue"), density = 50, angle = 90)
legend("topright", c("Current > Expected income", "Current < Expected income"),
fill = c("blue", "red"),
cex = 0.8)
Результат :
![enter image description here](https://i.stack.imgur.com/o9WD6.png)