standardVisual: Produce distribution plots using ggplot from ggplot2.

Description Usage Arguments Details See Also Examples

View source: R/standardVisual.R

Description

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.

Usage

1
standardVisual(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, 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, (haven_)labelled and logical variables, only NA values are removed.

See Also

visualize, basicVisual

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
## 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)

## End(Not run)

Example output

Loading required package: ggplot2
[1] "ggAggHist(data = structure(list(xmin = c(0, 2, 4, 6, 8), xmax = c(2, "       
[2] "4, 6, 8, 10), ymin = c(0, 0, 0, 0, 0), ymax = c(2L, 2L, 2L, 2L, "            
[3] "2L)), .Names = c(\"xmin\", \"xmax\", \"ymin\", \"ymax\"), row.names = c(NA, "
[4] "-5L), class = \"data.frame\"), vnam = \"MyVar\")"                            

dataMaid documentation built on Oct. 8, 2021, 9:08 a.m.