Title: | Descriptive Statistics |
---|---|
Description: | Performs various analyzes of descriptive statistics, including correlations, graphics and tables. |
Authors: | Emmanuel Arnhold |
Maintainer: | Emmanuel Arnhold <[email protected]> |
License: | GPL-2 |
Version: | 4.0 |
Built: | 2024-12-17 06:37:30 UTC |
Source: | CRAN |
The package performs various analyzes of descriptive statistics, including correlations
Package: | ds |
Type: | Package |
Version: | 4.0 |
Date: | 2018-07-07 |
License: | GPL-2 |
Emmanuel Arnhold
KAPS, M. and LAMBERSON, W. R. Biostatistics for Animal Science: an introductory text. 2nd Edition. CABI Publishing, Wallingford, Oxfordshire, UK, 2009. 504p.
# Example of weights and heart girths of cows. # Weight was measured in kg and heart girth in cm on 10 cows (Kaps and Lamberson, 2009). Weight=c(641, 620, 633, 651, 640, 666, 650, 688, 680, 670) Heart_girth=c(205, 212, 213, 216, 216, 217, 218, 219, 221, 226) data=data.frame(Weight,Heart_girth) r1<-dscor(data) r1 r2<-dscor(data, option=2) r2 r3<-dscor(data, method=2, option=1) r3 r4<-dscor(data, method=2, option=2) r4 r5<-gds(data) r5
# Example of weights and heart girths of cows. # Weight was measured in kg and heart girth in cm on 10 cows (Kaps and Lamberson, 2009). Weight=c(641, 620, 633, 651, 640, 666, 650, 688, 680, 670) Heart_girth=c(205, 212, 213, 216, 216, 217, 218, 219, 221, 226) data=data.frame(Weight,Heart_girth) r1<-dscor(data) r1 r2<-dscor(data, option=2) r2 r3<-dscor(data, method=2, option=1) r3 r4<-dscor(data, method=2, option=2) r4 r5<-gds(data) r5
Plot dispersion of first column of data in relation other columns
dplot(data, xlab = "Variable x", ylab = "Variable y", position = 1, colors = TRUE, type = "o", mean=TRUE)
dplot(data, xlab = "Variable x", ylab = "Variable y", position = 1, colors = TRUE, type = "o", mean=TRUE)
data |
data is a data.frame |
xlab |
x-axis title |
ylab |
y-axis title |
position |
position of legend top=1 (default) bottomright=2 bottom=3 bottomleft=4 left=5 topleft=6 topright=7 right=8 center=9 |
colors |
colors lines =TRUE (default) or black lines =FALSE |
type |
type of plot (see the plot function) |
mean |
plot means = TRUE (default) or plot original data = FALSE |
Emmanuel Arnhold
dscor, gds, tables
Time=c(10,20,30,40,50,60,70) x=c(1,3,5,6,7,9,6) y=c(4,6,8,9,10,15,16) z=c(1,5,18,19,22,20,15) data=data.frame(Time,x,y,z) dplot(data)
Time=c(10,20,30,40,50,60,70) x=c(1,3,5,6,7,9,6) y=c(4,6,8,9,10,15,16) z=c(1,5,18,19,22,20,15) data=data.frame(Time,x,y,z) dplot(data)
The function estimates and test correlations
dscor(data, method = 1, option = 1)
dscor(data, method = 1, option = 1)
data |
data is a data.frame or matrix |
method |
method = 1 Pearson (default) method = 2 Spearman |
option |
option = 1 return data.frame (default) option = 2 return matrix |
The function returns correlations (Pearson and Spearman) and probability values of the t test
In option = 2 (return matrix), diagonally above contains the correlations and diagonally below contains the p-values of t test
Emmanuel Arnhold
KAPS, M. and LAMBERSON, W. R. Biostatistics for Animal Science: an introductory text. 2nd Edition. CABI Publishing, Wallingford, Oxfordshire, UK, 2009. 504p.
gds, cor, cor.test
# Example of weights and heart girths of cows. # Weight was measured in kg and heart girth in cm on 10 cows (Kaps and Lamberson, 2009). Weight=c(641, 620, 633, 651, 640, 666, 650, 688, 680, 670) Heart_girth=c(205, 212, 213, 216, 216, 217, 218, 219, 221, 226) data=data.frame(Weight,Heart_girth) #Pearson (table) r1<-dscor(data) r1 # Pearson (matrix) r2<-dscor(data, option=2) r2 # Spearman (table) r3<-dscor(data, method=2, option=1) r3 # Spearman (matrix) r4<-dscor(data, method=2, option=2) r4 # fictional example var1=c(10,13,14,16,18,22,29,28,35) var2=c(0.5,1,1.5,2,2.5,3,3.5,4,4.5) var3=c(102,NA,106,91,109,108,120,101,NA) var4=c(500,456,423,378,312,263,200,120,50) var5=c(18,09,22,NA,26,59,10,NA,96) table=data.frame(var1,var2,var3,var4,var5) #Pearson r5<-dscor(table) r5 r6<-dscor(table, option=2) r6 # Spearman r7<-dscor(table, method=2, option=1) r7 r8<-dscor(table, method=2, option=2) r8
# Example of weights and heart girths of cows. # Weight was measured in kg and heart girth in cm on 10 cows (Kaps and Lamberson, 2009). Weight=c(641, 620, 633, 651, 640, 666, 650, 688, 680, 670) Heart_girth=c(205, 212, 213, 216, 216, 217, 218, 219, 221, 226) data=data.frame(Weight,Heart_girth) #Pearson (table) r1<-dscor(data) r1 # Pearson (matrix) r2<-dscor(data, option=2) r2 # Spearman (table) r3<-dscor(data, method=2, option=1) r3 # Spearman (matrix) r4<-dscor(data, method=2, option=2) r4 # fictional example var1=c(10,13,14,16,18,22,29,28,35) var2=c(0.5,1,1.5,2,2.5,3,3.5,4,4.5) var3=c(102,NA,106,91,109,108,120,101,NA) var4=c(500,456,423,378,312,263,200,120,50) var5=c(18,09,22,NA,26,59,10,NA,96) table=data.frame(var1,var2,var3,var4,var5) #Pearson r5<-dscor(table) r5 r6<-dscor(table, option=2) r6 # Spearman r7<-dscor(table, method=2, option=1) r7 r8<-dscor(table, method=2, option=2) r8
The function performs various analyzes of descriptive statistics
gds(data)
gds(data)
data |
data is a numeric vector, data.frame or matrix |
The function return mean, maximum, minimum, median, mean + or - standard deviation, quantiles, n, range, variance, standard deviation, standard error of the mean, coefficiente of variation, skewness, kurtosis, normality test (p-value of the Shapiro-Wilk test)
Emmanuel Arnhold
KAPS, M. and LAMBERSON, W. R. Biostatistics for Animal Science: an introductory text. 2nd Edition. CABI Publishing, Wallingford, Oxfordshire, UK, 2009. 504p.
dscor, cor, cor.test, summary
# Example of weights and heart girths of cows. # Weight was measured in kg and heart girth in cm on 10 cows (Kaps and Lamberson, 2009). Weight=c(641, 620, 633, 651, 640, 666, 650, 688, 680, 670) Heart_girth=c(205, 212, 213, 216, 216, 217, 218, 219, 221, 226) r1<-gds(Weight) r1 r2<-gds(Heart_girth) r2 data=data.frame(Weight,Heart_girth) r3<-gds(data) r3 # fictional example var1=c(10,13,14,16,18,22,29,28,35) var2=c(0.5,1,1.5,2,2.5,3,3.5,4,4.5) var3=c(102,NA,106,91,109,108,120,101,NA) var4=c(500,456,423,378,312,263,200,120,50) var5=c(18,09,22,NA,26,59,10,NA,96) table=data.frame(var1,var2,var3,var4,var5) r6=gds(table) r6 #kurtosis r6[24,] r6[24,]-3
# Example of weights and heart girths of cows. # Weight was measured in kg and heart girth in cm on 10 cows (Kaps and Lamberson, 2009). Weight=c(641, 620, 633, 651, 640, 666, 650, 688, 680, 670) Heart_girth=c(205, 212, 213, 216, 216, 217, 218, 219, 221, 226) r1<-gds(Weight) r1 r2<-gds(Heart_girth) r2 data=data.frame(Weight,Heart_girth) r3<-gds(data) r3 # fictional example var1=c(10,13,14,16,18,22,29,28,35) var2=c(0.5,1,1.5,2,2.5,3,3.5,4,4.5) var3=c(102,NA,106,91,109,108,120,101,NA) var4=c(500,456,423,378,312,263,200,120,50) var5=c(18,09,22,NA,26,59,10,NA,96) table=data.frame(var1,var2,var3,var4,var5) r6=gds(table) r6 #kurtosis r6[24,] r6[24,]-3
Organizes various tables of categorical variables and tests tables (Chi-square and Fisher's exact test)
tables(data)
tables(data)
data |
data is a data.frame |
Emmanuel Arnhold
gds, dscor, dplot
treatments=gl(2, 30, labels = c("Control", "Treat")) resultsA=rep(c("positive","negative", "positive","negative"),c(25,5,7,23)) resultsB=rep(c("positive","negative", "positive","negative"),c(28,2,8,22)) resultsC=rep(c("positive","negative", "positive","negative"),c(16,14,13,17)) data=data.frame(treatments,resultsA, resultsB, resultsC) r=tables(data) names(r) r r[1] r[2] r[6]
treatments=gl(2, 30, labels = c("Control", "Treat")) resultsA=rep(c("positive","negative", "positive","negative"),c(25,5,7,23)) resultsB=rep(c("positive","negative", "positive","negative"),c(28,2,8,22)) resultsC=rep(c("positive","negative", "positive","negative"),c(16,14,13,17)) data=data.frame(treatments,resultsA, resultsB, resultsC) r=tables(data) names(r) r r[1] r[2] r[6]
The function performs input tables of the environment R
X(x)
X(x)
x |
x is NULL |
insert
X ()
select the desired table and press enter
observation: the mouse cursor should be in front of X ()
returns a data.frame
Emmanuel Arnhold
gds, dscor
#X()
#X()