
Last chance! 50% off unlimited learning
Sale ends in
Plot the distribution of a variable, depending on its data class, by use of ggplot2.
Note that standardVisual
is a visualFunction
, compatible with the
visualize
and makeDataReport
functions.
standardVisual(v, vnam, doEval = TRUE)
The variable (vector) to be plotted.
The name of the variable which will appear as the title of the plot.
If TRUE, the plot itself is returned. Otherwise, the function returns a character string containing standalone R code for producing the plot.
For character, factor, logical and labelled variables, a barplot is produced. For numeric,
integer or Date variables, standardVisual
produces a histogram instead. Note that for
integer and numeric variables, all non-finite (i.e. NA
, NaN
, Inf
) values are
removed prior to plotting. For character, Date, factor, labelled and logical variables,
only NA
values are removed.
# NOT RUN {
#Save a variable
myVar <- c(1:10)
#Plot a variable
standardVisual(myVar, "MyVar")
#Produce code for plotting a variable
standardVisual(myVar, "MyVar", doEval = FALSE)
# }
Run the code above in your browser using DataLab