data(pitches)
strikeFX(pitches)
## Not run:
# strikeFX(pitches, layer=facet_grid(.~stand))
# #silly example on how to modify default settings and add layers
# strikeFX(pitches, color="", layer=facet_grid(s~stand))+
# geom_point(aes(x=px, y=pz, shape=pitch_types))+ #you could add color here
# geom_text(aes(x=px+0.5, y=pz, label=b))
#
# p <- strikeFX(pitches, geom="tile", layer=facet_grid(.~stand))
# p+theme(aspect.ratio=1)
#
# strikeFX(pitches, geom="hex", density1=list(des="Called Strike"), density2=list(des="Ball"),
# draw_zones=FALSE, contour=TRUE, layer=facet_grid(.~stand))
#
# noswing <- subset(pitches, des %in% c("Ball", "Called Strike"))
# noswing$strike <- as.numeric(noswing$des %in% "Called Strike")
# library(mgcv)
# m1 <- bam(strike ~ s(px, pz, by=factor(stand)) +
# factor(stand), data=noswing, family = binomial(link='logit'))
# # geom will automatically be set to 'raster'
# strikeFX(noswing, model=m1, layer=facet_grid(.~stand))
#
# m2 <- bam(strike ~ s(px, pz, by=factor(stand)) + s(px, pz, by=factor(inning_side)) +
# factor(stand) + factor(inning_side), data=noswing, family = binomial(link='logit'))
# strikeFX(noswing, model=m2, density1=list(inning_side="top"),
# density2=list(inning_side="bottom"), layer=facet_grid(.~stand))
# ## End(Not run)
Run the code above in your browser using DataLab