Learn R Programming

dataMaid (version 1.4.1)

basicVisual: Produce distribution plots in the base R (graphics) style using plot and barplot

Description

Plot the distribution of a variable, depending on its data class, using the base R plotting functions. Note that basicVisual is a visualFunction, compatible with the visualize and makeDataReport functions.

Usage

basicVisual(v, vnam, doEval = TRUE)

Arguments

v

The variable (vector) to be plotted.

vnam

The name of the variable which will appear as the title of the plot.

doEval

If TRUE, the plot itself is returned. Otherwise, the function returns a character string containing standalone R code for producing the plot.

Details

For character, factor, logical and (haven_)labelled variables, a barplot is produced. For numeric, integer or Date variables, basicVisual 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, factor, (haven_)labelled and logical variables, only NA values are removed.

See Also

visualize, standardVisual

Examples

Run this code
# NOT RUN {
 
# }
# NOT RUN {
 #Save a variable
   myVar <- c(1:10)
 #Plot a variable
   basicVisual(myVar, "MyVar")

 #Produce code for plotting a variable
   basicVisual(myVar, "MyVar", doEval = FALSE)
 
# }

Run the code above in your browser using DataLab