(This vignette is still in a draft).

ggplot2 provides a comprehensive collection of functions to draw a variety of informative plots.

library(ggplot2)
ggplot(iris) +
geom_point(aes(x=Sepal.Width,
               y=Sepal.Length,
               colour=Species,
               size=Petal.Width))

ggbash is a different and faster interface for the ggplot2. In ggbash, you can plot the same figure by the following command:

ggbash( ggplot(iris) + point(x=Sepal.W, y=Sepal.L, col=Species, sz=Petal.W) )

The above ggbash source code (ggplot(iris) + point(x=Sepal.W, y=Sepal.L, col=Species, sz=Petal.W)) displays exactly the same plot of the first ggplot2 command.

faster way

how to use in R session

principles of ggplot2

Why does that command work?

If you are experienced R users, you might have been surprised by the above command. Especially if you see the following output:

point
Error: no such object 'point'

The point() function used above is undefined in R global environment --

Essentially, ggbash is a higher-level language for ggplot2. It compiles a short ggbash "source code" to an "executable" ggplot2 object like this:

library(ggbash)

ggbash(iris) # enter in a ggbash session with the 'iris' data frame

```{bash, eval=FALSE} user@host currentDir (iris) $ point Sepal.W Sepal.L c=Sp si=Petal.W | echo

```r
executed:
ggplot(iris) +
geom_point(aes(x=Sepal.Width,
               y=Sepal.Length,
               colour=Species,
               size=Petal.Width))
ggplot(iris) +
geom_point(aes(x=Sepal.Width,
               y=Sepal.Length,
               colour=Species,
               size=Petal.Width))

If you prefer least possible typing,

```{bash, eval=FALSE}

specify by column indices

user@host currentDir (iris) $ p 2 1 c=5 si=4 ```

gives exactly the same plot. The original ggplot2 notation needs 91 characters (whitespaces are not counted) to draw the above plot, whereas the ggbash version of notation only with 10 characters. This means that ggbash enables more than 80% reduction of key strokes. The differece becomes much larger with more complicated plots.



caprice-j/ggbash documentation built on May 13, 2019, 12:11 p.m.