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 |
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.
gg_(query = NULL)
gg_(query = NULL)
query |
Character. A natural language command related to the styling of a ggplot. |
'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.
An object of class 'gg' from the internal class system of 'ggplot2'
## 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)
## 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 string. Queries should be related to the styling of the plot, such as, axis label font size, axis label title, legend, and similar.
gghelp(query = "", print = TRUE)
gghelp(query = "", print = TRUE)
query |
Character. A natural language command related to the styling of a ggplot. |
print |
Boolean. Print out the command or just return it. |
'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.
Returns a string if there is a matching ggplot command in the database. Otherwise returns NULL.
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'")
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'")