graph_code | R Documentation |
graph_code is an educational function used to learn about how to write code using the ggplot2 package for different types of graphs generated by the what_graph function GGHelper
graph_code(df, type, x, y = NULL, color = NULL)
df |
A data frame. |
type |
The name (in quotes) of the graph of interest. |
x |
The first variable of interest (will go on the x axis of the graph) |
y |
An additional variable of interest (will go on the y axis of the graph) |
color |
An additional variable of interest (will be used as the color argument of the graph) |
It is important that before this function is used, the columns of interest have the correct data type. Specifically, a categorical or discrete variable needs to have a data type of 'factor' and a continuous variable needs to have a data type of 'numeric'
Additionally, in order for the function to work, the variables that are input in the function need to be contained inside the data set that is input.
graph_code returns a printed output which contains the code to create the graph of interest with variable names in their correct places, along with information about when the usage of the graph of interest.
graph_code(iris, "Scatter Plot", x = Sepal.Length, y = Sepal.Width)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.