Package 'ggx'

Title: A Natural Language Interface to 'ggplot2'
Description: The 'ggplot2' package is the state-of-the-art toolbox for creating and formatting graphs. However, it is easy to forget how certain formatting commands are named and sometimes users find themselves asking: How do you rotate the x-axis labels again? Or how do you hide the legend...? This package allows users to issue natural language commands related to theme-related styling of plots (colors, font size and such), which then are translated into valid 'ggplot2' commands.
Authors: Andreas M. Brandmaier [aut, cre], Cyrus Eosphoros [ctb]
Maintainer: Andreas M. Brandmaier <[email protected]>
License: GPL-3
Version: 0.1.3
Built: 2024-11-08 03:57:59 UTC
Source: https://github.com/brandmaier/ggx

Help Index


Transforms a natural language query into a gg object

Description

Converts a natural language query into a 'gg' object, which can be directly chained to a 'ggplot'-call. Queries should be related to the styling of the plot, such as, axis label font size, axis label title, legend, and similar.

Usage

gg_(query = NULL)

Arguments

query

Character. A natural language command related to the styling of a ggplot.

Details

'gg_' calls the function 'gghelp', which maintains a database of keywords that match typical queries related to styling 'ggplot2' graphs. Based on the users natural language query, the function tries to find the best match and then returns the ggplot2 command, such that the result of a call to 'gg_' can be chained directly to a 'ggplot()' call.

Value

An object of class 'gg' from the internal class system of 'ggplot2'

See Also

gghelp

Examples

## Not run: 
library(ggplot2)
ggplot(data=iris,
mapping=aes(x=Sepal.Length,
           y=Petal.Length, color=Species))+
 geom_point()+
 gg_("rotate x-axis labels by 90°")+
 gg_("set x-axis label to 'Length of Sepal'")
 
## End(Not run)

Converts a natural language query into a 'ggplot2' command.

Description

Converts a natural language query into a 'ggplot2' command string. Queries should be related to the styling of the plot, such as, axis label font size, axis label title, legend, and similar.

Usage

gghelp(query = "", print = TRUE)

Arguments

query

Character. A natural language command related to the styling of a ggplot.

print

Boolean. Print out the command or just return it.

Details

'gghelp' maintains a database of keywords that match typical queries related to styling 'ggplot2' graphs. Based on the users natural language query, the function tries to find the best match and then returns the ggplot2 command as string.

Value

Returns a string if there is a matching ggplot command in the database. Otherwise returns NULL.

See Also

gg_

Examples

gghelp("rotate x-axis labels by 90 degrees")

gghelp("increase font size on x-axis label")

gghelp("set x-axis label to 'Length of Sepal'")