freq: Calculate a frequency table

Description Usage Arguments Details Value Note Author(s) See Also Examples

Description

Calculates one or more frequency table(s) from a vector, matrix or data frame.

Usage

1
 freq(x,variable.labels=NULL,display.na=TRUE,decr.order=TRUE)

Arguments

x

a vector, matrix or data frame.

variable.labels

optional labels for the variables. The default is the name of the variable passed or the names attribute if the variable has more than 1 dimension.

display.na

logical - whether to display counts of NAs.

decr.order

Whether to order each frequency table in decreasing order.

Details

freq calls table to get the frequency counts and builds a list with one or more components containing the value labels and counts.

Value

A list with one or more components. Each component includes the values of the relevant variable as the names.

Note

The limit on the number of bins has been removed, so passing a numeric vector with many levels may produce a huge, useless "frequency" table.

Author(s)

Jim Lemon

See Also

print.freq

Examples

1
2
3
4
5
6
 A<-sample(1:10,130,TRUE)
 A[sample(1:130,6)]<-NA
 C<-sample(LETTERS[1:14],130,TRUE)
 C[sample(1:130,7)]<-NA
 test.df<-data.frame(A,C)
 freq(test.df)

Example output

Frequencies for A 
        1    5    8    3   10    6    2    9    7    4   NA
       19   18   15   14   12   11   10   10    9    6    6
%    14.6 13.8 11.5 10.8  9.2  8.5  7.7  7.7  6.9  4.6  4.6 
%!NA 15.3 14.5 12.1 11.3  9.7  8.9  8.1  8.1  7.3  4.8 


Frequencies for C 
        L    C    F    B    E    A    D    M    J    H    N    I    K    G   NA
       15   13   13   12   10    9    9    9    8    7    7    5    4    2    7
%    11.5   10   10  9.2  7.7  6.9  6.9  6.9  6.2  5.4  5.4  3.8  3.1  1.5  5.4 
%!NA 12.2 10.6 10.6  9.8  8.1  7.3  7.3  7.3  6.5  5.7  5.7  4.1  3.3  1.6 

prettyR documentation built on May 2, 2019, 2:16 a.m.

Related to freq in prettyR...