ABSTRACT

The primary data visualization for a categorical variable is the bar chart for one or two variables or a pie chart for a single variable. Construct the bar chart from the data table directly of the original data values or begin with a summary table of those values, such as counts or means or mean deviations of a numeric variable for the different levels of the categorical variable. Also, consider a bar chart of two variables called the “100% stacked bar chart” to highlight differences between categories in terms of percentages instead of frequencies. The corresponding lessR functions are BarChart() and PieChart(). As with all lessR data visualization functions, set the overall theme with the style function and choose a theme by its color name, such as dark red. Or, for a specific data visualization, use the fill parameter to modify the color of objects such as bars or points. Modify the edges of plotted objects with the color parameter. The bar chart for one variable is constructed from a table of frequencies or a table of joint frequencies for two variables. The Chi-square test is used to generalize the corresponding probabilities to the population to inferential statistics. Use the lessR function pivot() to construct frequency tables apart from the bar chart function.