ggbash: execute a specified ggbash command

Description Usage Arguments Details Examples

Description

ggbash() can be used as follows: 1. ggbash() : with no argument (enter into an interactive ggbash session) 2. ggbash("gg mtcars + point mpg cyl") : with a character argument 3. ggbash( gg(mtcars) + point(mpg,cyl)) : with ggbash commands and a dataset 4. mtcars

Usage

1
2
ggbash(ggbash_symbols = "", clipboard = NULL, show_warn = TRUE,
  as_string = FALSE, show_compiled = TRUE)

Arguments

ggbash_symbols

Non-evaluated R symbols or a character representing ggbash commands. If no ggbash_symbols are specified, enter into an interactive ggbash session.

clipboard

Default is NULL. If non-null, copy the resulted string to clipboard.

show_warn

If ambiguously matched, display warning. Default is TRUE.

as_string

Return a string instead of a ggplot2 object. Default is FALSE.

show_compiled

Print the built ggplot2 command. Default is TRUE.

Details

In 1 and 2 cases, parentheses and commas are optional in ggbash commands, whereas 3 and 4 can only interpret commands with parentheses and commas because of R's default token constraints.

ggbash features partial match for the following elements: 1. ggplot() function (any of ggplot(), gg() and g() works) 2. geom names (geom_point can be specified by point or even p) 3. aesthetics names (size by sz, color by col or c ) 4. column names (prefix match only, no fuzzy match. When ambiguous, the column with the smallest column index is used) 5. theme element names (legend.text by l.txt, axis.title.x by a.ttl.x)

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
## Not run: 

# Case 1: ggbash() with no argument

ggbash() # ggbash() enters into an interactive ggbash session

# Case 2: with a character arugment

## parentheses and commas become optional

ggbash("gg iris  + point Sepal.W  Sepal.L  color=Species ")
ggbash("gg iris  + point Sepal.W, Sepal.L, color=Species ")
ggbash("gg(iris) + point(Sepal.W, Sepal.L, color=Species)")

## all of the above work


# Case 3: with a short-ggplot2 command

## sm: geom_smooth
ggbash(gg(iris, Sepal.W, Sepal.L, c=Sp) + point + sm(method="lm", se=FALSE)
       + theme(a.txt(sz=25, face="bold"), l.pos("bottom")) )

## if you prefer more ggplot2-compliant syntax
ggbash(ggplot(iris, Sepal.Width, Sepal.Length, colour = Species) +
       geom_point() + geom_smooth(method = "lm", se = FALSE) +
       theme(axis.text(size=25, face="bold"), legend.position("bottom")) )

## or if you prefer an extreme short syntax
ggbash(g(iris, Sepal.W, S, c=Sp) + p + sm(mth="lm", se=FALSE)
       + theme(a.tx(s=25, f="bold"), l.pos("bottom")))

## S ambiguously matches to Sepal.Length, Sepal.Width, Species.
## Since the Sepal.Length has the smallest column index, it's selected


# Case 4: dataset piped from dplyr/tidyr

iris %>%
    mutate(my_long_descriptive_column_name = Sepal.Width,
           other_useful_informative_name = Sepal.Length) %>%
    ggbash(gg() + point(my, other))


## End(Not run)

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