graph_code: Code and Info for Graphs

View source: R/graph_code.R

graph_codeR Documentation

Code and Info for Graphs

Description

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

Usage

graph_code(df, type, x, y = NULL, color = NULL)

Arguments

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)

Details

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.

Value

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.

Examples

graph_code(iris, "Scatter Plot", x = Sepal.Length, y = Sepal.Width)


rachael-ryan/Lab4Package documentation built on June 11, 2022, 7:20 a.m.