descdata {dataprep} | R Documentation |
Fast descriptive statistics
Description
It describes data using R basic functions, without calling other packages to avoid redundant calculations, which is faster.
Usage
descdata(data, start = NULL, end = NULL, stats= 1:9, first = "variables")
Arguments
data |
A data frame to describe, from the column |
start |
The column number of the first variable to describe. |
end |
The column number of the last variable to describe. |
stats |
Selecting or rearranging the items from the 9 statistics, i.e., n, na, mean, sd, median, trimmed, min, max, and IQR. It can be a vector or a single value, in 'character' or 'numeric' class. |
first |
The name of the first column of the output. It is the general name of the items (variables). |
Details
This function can be used for different types of data, as long as the variables are numeric. Because it describes the data frame from the column start
to the column end
, the variables need to be linked together instead of being scattered.
Value
A data frame of descriptive statistics:
size |
default general name of items (variables). Users can define it via the parameter first. |
n |
number of valid cases |
na |
number of invalid cases |
mean |
mean of each item |
sd |
standard deviation |
median |
median of each item |
trimmed |
trimmed mean (with trim defaulting to .1) |
min |
minimum of each item |
max |
maximum of each item |
IQR |
interquartile range of each item |
Author(s)
Chun-Sheng Liang <liangchunsheng@lzu.edu.cn>
References
1. Example data is from https://smear.avaa.csc.fi/download. It includes particle number concentrations in SMEAR I Varrio forest.
See Also
dataprep::descplot
Examples
# Variable names are essentially numeric
descdata(data,5,65)
# Use numbers to select statistics
descdata(data,5,65,c(2,7:9))
# Use characters to select statistics
descdata(data,5,65,c('na','min','max','IQR'))
# When type of variable names is character
descdata(data1,3,7)
# Use numbers to select statistics
descdata(data1,3,7,c(2,7:9))
# Use characters to select statistics
descdata(data1,3,7,c('na','min','max','IQR'))