I want to make a plot with ggplot between Names in X-axis and Average_Working_hours in y-axis. How can I fill the bar with colors depended in the value of average working hours? My data looks like the following:
If someone works for more than 8 hours, the bar should be fill with red, otherwise fill with blue?
That's my code:
ggplot(Report, aes(x=Report$Name,y=Report$average_working_hours)) + ggtitle('working hours in July') + ylab(' working hours')+ geom_bar(stat = 'identity', fill = ifelse(Report$average_working_hours > 8){"red"} else {"blue"})+ theme_gray()
gived me the warning :
In if (Report$average_working_hours > 8) { : the condition has length > 1 and only the first element will be used
and all the bar is filled with blue: