Type: | Package |
Title: | Easy Frequency Tables |
Version: | 0.4.1 |
Author: | Alistair Wilcox |
Maintainer: | Alistair Wilcox <frequency@alistairwilcox.com> |
Description: | Generate 'SPSS'/'SAS' styled frequency tables. Frequency tables are generated with variable and value label attributes where applicable with optional html output to quickly examine datasets. |
Depends: | R (≥ 3.0), rmarkdown, knitr, DT, ggplot2 |
Imports: | gtools, utils |
Suggests: | foreign, haven, testthat, covr, shiny |
SystemRequirements: | pandoc (>= 1.12.3) - http://pandoc.org |
License: | GPL-3 |
LazyData: | TRUE |
RoxygenNote: | 7.1.1 |
URL: | https://github.com/wilcoxa/frequency |
BugReports: | https://github.com/wilcoxa/frequency/issues |
NeedsCompilation: | no |
Packaged: | 2021-01-11 13:14:56 UTC; Al |
Repository: | CRAN |
Date/Publication: | 2021-01-11 14:00:03 UTC |
frequency: A package to generate frequencies
Description
The frequency package comprises functions to generate SPSS like frequencies in R.
Frequency functions
See Also
Useful links:
Big 5 Personality Factors Survey Data
Description
Answers to the Big Five Personality Test, constructed with items from the International Personality Item Pool.
Usage
data(big5)
Format
A dataframe
Source
Open psychology data: Raw data from online personality tests
Examples
data(big5)
Freq
Description
This function generates frequency tables
Usage
freq(
x,
file = NULL,
weight = NULL,
maxrow = 30,
type = "html",
template = NULL
)
Arguments
x |
Input data. Can be a dataframe, list or vector. |
file |
File name. Optional file name to save the output. |
weight |
Weight variable name. (Note: this is a placeholder and not currently implemented) |
maxrow |
Maximum number of rows to display in each frequency table. |
type |
Output type. Either html or doc. |
template |
Word template. Optional doc template to use if producing doc output. |
Value
A frequency table in html or doc format.
Examples
# Suppress external output for examples
options(frequency_render = FALSE)
# Create frequency tables for the entire dataset
freq(big5)
# For specific variable/s
freq(big5[5:6])
freq(big5$country)
# Produce a list of tables
out <- freq(big5[8:10])
out[1]
options(frequency_render = TRUE)
## Not run:
# To automatically open html output in your browser use the following option:
options(frequency_open_output = TRUE)
freq(big5[, c('gender', 'E1')])
# To save the output specify the filename and format
freq(big5, file = "mydir/myfile.html")
# Supports label attributes from the package foreign package
library(foreign)
dat <- read.spss(myfile)
freq(dat)
# (Note: foreign may drop attributes when using to.data.frame = TRUE)
df <- read.spss(myfile, to.data.frame = TRUE)
freq(df)
# Also supports label attributes from the haven package
library(haven)
dat <- read_sav(myfile)
freq(dat)
# as well as other data with no label attributes
dat <- data.frame(id = 1:3, val = letters[1:3])
freq(dat)
## End(Not run)
Print frequency tables
Description
S3 method for class 'freq_table'
Usage
## S3 method for class 'freq_table'
print(x, ...)
Arguments
x |
object of class |
... |
optional arguments to |
Examples
# Suppress external output for examples
options(frequency_render = FALSE)
x <- freq(big5[1])
print(x)
print(x[[1]])