Learn R Programming

AnalyzeTS (version 2.0)

Dgroup: Discriptives Follow Groups

Description

This function descriptive statistics in group for a continous variable. Usual using to statistic a time series following dates in week or months in year.

Usage

Dgroup(x, follow = NULL, r = 2, answer = 1, statistic = "ALL")

Arguments

x
A continous variable or a time series.
follow
A factor or a list factor which contain not too two factors.
r
Rounds the answer to the specified number of decimal places (default 2).
answer
Form of answers are returned. Let answer=1 or answer=2 (default 1).
statistic
A list contain descriptive statistic values that user want R print screen (default ALL).

Value

N
Length sample
NaN
Number NA values
Min
Min value
1sq QU
Value in 25% of interval probabilities
Median
Median value
Mean
Mean value
3rd QU
Value in 75% of interval probabilities
Max
Max value
VAR
Variance value
SD
Standard Deviation
SE
Standard Deviation of the Estimated Means

Details

Data is divided into groups by follow and then every group are calculated by Descriptives function.

References

Theory of base statistic.

See Also

Descriptives,Frequencies

Examples

Run this code
#Factor date
date<-as.factor(c("Tue","Wed","Thu","Fri","Mon","Tue","Wed","Thu","Fri","Mon",
"Tue","Wed","Thu","Fri","Mon","Tue","Wed","Thu","Fri","Mon","Tue","Wed","Thu",
"Fri","Mon","Tue","Wed","Thu","Fri","Mon","Tue","Wed","Thu"))

#Factor hk
hk<-as.factor(c("hk1","hk2","hk1","hk3","hk3","hk1","hk1","hk1","hk2","hk2","hk2",
"hk1","hk2","hk1","hk1","hk1","hk2","hk1","hk1","hk1","hk1","hk2","hk1",
"hk1","hk1","hk1","hk3","hk1","hk3","hk3","hk2","hk3","hk1"))

#A continous variable
coffee<-c(5,6,8,4,3,7,6,0,3,2,3,4,9,1,3,8,7,8,2,3,8,6,4,4,6,7,6,5,2,3,8,4,4)

#Descriptive statistics in group
Dgroup(coffee,r=4,answer=2)
Dgroup(coffee,follow=list(date),r=4)
Dgroup(coffee,follow=date,r=4,answer=2)
Dgroup(coffee,follow=date,r=4,statistic=list("Mean","Max"))
Dgroup(coffee,r=4,follow=list(date,hk),answer=1)
Dgroup(coffee,r=4,follow=list(date,hk),answer=2)
Dgroup(coffee,r=4,follow=list(hk,date),answer=1)
Dgroup(coffee,r=4,follow=list(hk,date),answer=2)

Run the code above in your browser using DataLab