Description Usage Arguments Details See Also Examples
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.
1 | basicVisual(v, vnam, doEval = TRUE)
|
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. |
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.
1 2 3 4 5 6 7 8 9 10 | ## 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)
## End(Not run)
|
Loading required package: ggplot2
[1] "plot(structure(list(breaks = c(0, 2, 4, 6, 8, 10), counts = c(2L, "
[2] "2L, 2L, 2L, 2L), density = c(0.1, 0.1, 0.1, 0.1, 0.1), mids = c(1, "
[3] "3, 5, 7, 9), xname = \"v\", equidist = TRUE), .Names = c(\"breaks\", "
[4] "\"counts\", \"density\", \"mids\", \"xname\", \"equidist\"), class = \"histogram\"), "
[5] " main = \"MyVar\", col = \"grey\", xlab = \"\")"
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.