
Last chance! 50% off unlimited learning
Sale ends in
To plot graph from same variable when Target=NULL vs. when Target = categorical variable (binary or multi-class variable)
ExpTwoPlots(
data,
plot_type = "numeric",
iv_variables = NULL,
target = NULL,
lp_geom_type = "boxplot",
lp_arg_list = list(),
rp_geom_type = "boxplot",
rp_arg_list = list(),
fname = NULL,
page = NULL,
theme = "Default"
)
This function returns same variable in two different views of ggplot in one graph. And there is a option to save the graph into PDF or JPEG format.
dataframe
the plot type ("numeric", "categorical").
list of independent variables. this input will be based off plot_type. List of numeric variables / List of categorical variables
binary or multi-class dependent variable
left side geom plot. this option is for univariate data. Options for numeric are "boxplot", "histogram", "density", "violin", "qqplot" and for categorical "bar", "pie", "donut"
arguments to be passed to lp_geom_type. Default is list()
right side geom plot. Options for numeric are "boxplot", "histogram", "density", "violin" "qqplot" and for categorical "bar", "pie", "donut"
arguments to be passed to rp_geom_type. Default is list()
output file name. Output will be generated in PDF format
output pattern. if Page=c(3,2), It will generate 6 plots with 3 rows and 2 columns
adding extra themes, geoms, and scales for 'ggplot2' (eg: themes options from ggthemes package)
## Bar graph for specified variable
# Let's consider mtcars data set, it has several numerical and binary columns
target = "gear"
categorical_features <- c("vs", "am", "carb")
numeircal_features <- c("mpg", "cyl", "disp", "hp", "drat", "wt", "qsec")
# plot numerical data two independent plots:
# Left side histogram chart wihtout target and Right side boxplot chart with target
num_1 <- ExpTwoPlots(mtcars, plot_type = "numeric",
iv_variables = numeircal_features, target = "gear",
lp_arg_list = list(alpha=0.5, color = "red", fill= "white",
binwidth=1),lp_geom_type = 'histogram',
rp_arg_list = list(fill = c("red", "green", "blue")),
rp_geom_type = 'boxplot', page = c(2,1),theme = "Default")
# plot categorical data with two independent plots:
# Left side Donut chart wihtout target and Right side Stacked bar chart with target
cat_1 <- ExpTwoPlots(mtcars,plot_type = "categorical",
iv_variables = categorical_features,
target = "gear",lp_arg_list = list(),lp_geom_type = 'donut',
rp_arg_list = list(stat = 'identity', ),
rp_geom_type = 'bar',page = c(2,1),theme = "Default")
Run the code above in your browser using DataLab