I am very new to R and thanks to the provided help here so far, I managed to create the following Barplot by using the following code:
res <- data.frame( aggregate( rentals ~ weatherCond + season, bikes, sum ))
res$weatherCond <- ordered(res$weatherCond,
levels = c(1, 2, 3, 4),
labels = c("Clear", "Fog", "Snow", "Storm"))
res$season <- factor(res$season,
levels = c(1, 2, 3, 4),
labels = c("Winter", "Spring", "Summer", "Autumn"))
par(mar=c(10,4,1,1)+.5)
barplot( res[,"rentals"], names=apply( res[,1:2], 1, function(x) paste0(x[1],"_",x[2]) ), las=3 )
The plot visualizes the connection between the number of RENTED bikes and the SEASONs depending on the WEATHER conditions (3 variables). The bars in the plot show the amount of bikes RENTED, separated into the corresponding SEASON/WEATHER combinations.
- How should I modify the code in order to display the number of rented bikes above every single bar in the barplot?
- How should I modify the code in order to adjust the colors: blue for every bar, which is "Winter", Green for "Spring", Red for "Summer" and Yellow for "Autumn". (I am also to open to ideas for distributing the colors in a better way).