single_freq | R Documentation |

generates a bar chart of class ggplot illustrating how responses are
distributed for a specific single-choice question. If you provide a grouping
variable using `group_by`

the chart includes facets for each subgroup.
Additionally, if you specify survey weights with `weights`

the chart reflects
weighted response frequencies.

```
single_freq(
dataset,
question,
group_by = NULL,
subgroups_to_exclude = NULL,
weights = NULL,
na.rm = FALSE
)
```

`dataset` |
The input dataframe (or tibble) of survey questions |

`question` |
The categorical variable of interest for which frequencies
and counts will be calculated, can be selected by using |

`group_by` |
Optional variable to group the analysis. If provided, the frequencies and counts will be calculated within each subgroup. |

`subgroups_to_exclude` |
Optional vector specifying subgroups to exclude from the analysis. |

`weights` |
Optional variable containing survey weights. If provided, frequencies and counts will be weighted accordingly. |

`na.rm` |
Logical indicating whether to remove NA values from |

A ggplot2 object with a bar chart displaying response frequencies. If "group_by" is provided, facets show subgroup details. If "weights" are specified, the chart displays weighted frequencies.

Other single-choice questions:
`single_summary()`

,
`single_table()`

```
#Simple barchart
single_freq(berlinbears, question = income)
#Use `group_by` to facet the graph into several groups
single_freq(berlinbears, question = income, group_by = gender)
#to ignore a subgroup, use `subgroups_to_exclude`
single_freq(berlinbears, question = income, group_by = species,
subgroups_to_exclude = c('black bear', NA))
#Specify survey weights with `weights`
single_freq(berlinbears, question = h_winter, group_by = gender, weights = weights)
#to ignore NA values in the responses to `question`, set na.rm = TRUE
single_freq(berlinbears, question = h_winter, na.rm = TRUE)
```

Embedding an R snippet on your website

Add the following code to your website.

For more information on customizing the embed code, read Embedding Snippets.