Syntax
Main Clauses
ggsql augments the standard SQL syntax with a number of new clauses to describe a visualisation:
VISUALISEinitiates the visualisation part of the queryDRAWadds a new layer to the visualisationSCALEspecify how an aesthetic should be scaledFACETdescribes how data should be split into small multiplesPROJECTis used for selecting the coordinate system to useLABELis used to manually add titles to the plot or the various axes and legends
Layers
There are many different layers to choose from when visualising your data. Some are straightforward translations of your data into visual marks such as a point layer, while others perform more or less complicated calculations like e.g. the histogram layer. A layer is selected by providing the layer name after the DRAW clause
pointis used to create a scatterplot layerlineis used to produce lineplots with the data sorted along the x axispathis likelineabove but does not sort the data but plot it according to its own orderbarcreates a bar chart, optionally calculating y from the number of records in each barhistogrambins the data along the x axis and produces a bar for each bin showing the number of records in it