Working on a win/loss sparkline in R. Data coded 1 for win and -1 for loss. Can get basic structure with ggplot and following code:
puck <- data.frame(game=c("g1", "g2", "g3", "g4"),
wnls=c(-1, 1, -1, 1))
head (puck)
library(ggplot2)
# sparkline via barplot, v1
plot1<-ggplot(data=puck, aes(x=game, y=wnls)) +
geom_bar(stat="identity", width=0.5)
plot1
Understand how to change all bars to one color. However, want to code the wins blue and losses red. Suggestions on how to do this? Thanks, RB
One way is to define a new column with wins and losses and then map
fillto aesthetics: