Learn R Programming

userfriendlyscience (version 0.1-2)

freq: Freq

Description

Function to show frequencies in a manner similar to what SPSS' "FREQUENCIES" command does.

Usage

freq(vector, digits = 1, nsmall=1, transposed=FALSE, round=1)

Arguments

vector
A vector of values to compute frequencies for.
digits
Minimum number of significant digits to show in result.
nsmall
Minimum number of digits after the decimal point to show in the result.
transposed
Whether to transpose the results when printing them (this can be useful for blind users).
round
Number of digits to round the results to (can be used in conjunction with digits to determine format of results).

Value

  • An object with several elements, the most notable of which is:
  • datA dataframe with the frequencies

Examples

Run this code
### Create factor vector
ourFactor <- factor(mtcars$gear, levels=c(3,4,5),
                    labels=c("three", "four", "five"));
### Add some missing values
factorWithMissings <- ourFactor;
factorWithMissings[10] <- factorWithMissings[20] <- NA;

### Show frequencies
freq(ourFactor);
freq(factorWithMissings);

Run the code above in your browser using DataLab