report.quanti Returns quantitative descriptive statistics such as mean, median, standard deviation etc...

For more examples see the website: ClinReport website

report.quanti(data, y, x1 = NULL, x2 = NULL, y.label = y,
  round = 2, total = F, scientific = F, digits = NULL,
  at.row = NULL, subjid = NULL, geomean = F, add.mad = F,
  default.stat = T, func.stat = NULL, stat.name = "Statistics",
  func.stat.name = "", drop.x1 = NULL, drop.x2 = NULL)

Arguments

data

Data.frame object

y

Character indicating a numerical vector in the data frame passed to data argument

x1

Character indicating a factor in the data (levels will be displayed in columns)

x2

Character indicating a factor in the data (levels will be displayed in lines)

y.label

Character Indicates the label for y parameter to be displayed in the title of the table

round

Numeric to indicate how to round statistics

total

Logical to indicate if a "Total" column should be added

scientific

Logical Indicates if statistics should be displayed in scientific notations or not

digits

Numeric (used if scientific=TRUE) to indicate how many digits to use in scientific notation

at.row

Character Used to space the results (see examples)

subjid

Character Indicates the column in which there is the subject Id to add the number of subjects in the column header if x1 and x2 are not null.

geomean

Logical If yes geometric mean is calculated instead of arithmetic mean: exp(mean(log(x),na.rm=TRUE)) for x>0

add.mad

Logical If yes the Median Absolute Deviance is added to the median statistics (see function mad)

default.stat

Logical (default to TRUE). If FALSE you can specify your own example

func.stat

Function. If specified then default.stat=FALSE and only the specified statistic is reported

stat.name

Character. Indicates the name of the variable that report the statistics Default = "Statistics"

func.stat.name

Character. Used only if default.stat=FALSE. Indicates the name of specific statistic you want to report

drop.x1

Character. Indicates one or several levels of the x1 factor that you want to drop in the result

drop.x2

Character. Indicates one or several levels of the x2 factor that you want to drop in the result

Value

A desc object.

Details

This function computes and reports quantitative statistics on y. And can gives the statistics by level of two factors (x1 in columns and/or x2 in rows). See the example to show the results. If total=TRUE, the last column is the statistics performed overall levels of x1 for each levels of x2. Quantiles are calculated using type 3 (SAS presumed definition) algorithms, but even though, some differences between SAS and R can appear on quantile values.

"geomean" compute the geometric mean defined as exp(mean(log(y))). The values below or equal 0 are removed and a message is printed to indicate how many values were deleted to calculate the geometric mean.

N returns the number of observations (including NA values)

stat.name is automatically transformed using make.names function.

See also

Examples

data(datafake) # Quantitative statistics with no factor report.quanti(data=datafake,y="y_numeric",total=TRUE,y.label="Awesome results")
#> #> ############################################ #> Quantitative descriptive statistics of: Awesome results #> ############################################ #> #> Statistics Awesome results Total #> 6 N 396 396 #> 3 Mean (SD) 2.56(2.20) 2.56(2.20) #> 4 Median 2.71 2.71 #> 2 [Q1;Q3] [1.04;4.33] [1.04;4.33] #> 1 [Min;Max] [-2.99;7.96] [-2.99;7.96] #> 5 Missing 10 10 #> #> ############################################ #>
#' # Quantitative statistics with no factor with geometric mean (option geomean=TRUE) report.quanti(data=datafake,y="y_numeric",y.label="Awesome results",geomean=TRUE)
#> 66 values were removed to calculate the Geometric mean
#> #> ############################################ #> Quantitative descriptive statistics of: Awesome results #> ############################################ #> #> Statistics Awesome results #> 1 N 396 #> 3 Geo Mean (SD) 2.52(2.20) #> 6 Median 2.71 #> 4 [Q1;Q3] [1.04;4.33] #> 5 [Min;Max] [-2.99;7.96] #> 2 Missing 10 #> #> ############################################ #>
# Quantitative statistics with one factor report.quanti(data=datafake,y="y_numeric",x1="GROUP")
#> #> ############################################ #> Quantitative descriptive statistics of: y_numeric #> ############################################ #> #> Statistics A B C #> 1 N 180 120 96 #> 3 Mean (SD) 1.46(1.50) 3.15(2.00) 3.87(2.52) #> 6 Median 1.59 3.75 4.73 #> 4 [Q1;Q3] [0.45;2.50] [2.46;4.44] [3.44;5.30] #> 5 [Min;Max] [-2.34;4.36] [-2.44;6.19] [-2.99;7.96] #> 2 Missing 4 4 2 #> #> ############################################ #>
# One factor with total column report.quanti(data=datafake,y="y_numeric",x1="GROUP",total=TRUE)
#> #> ############################################ #> Quantitative descriptive statistics of: y_numeric #> ############################################ #> #> Statistics A B C Total #> 6 N 180 120 96 396 #> 3 Mean (SD) 1.46(1.50) 3.15(2.00) 3.87(2.52) 2.56(2.20) #> 4 Median 1.59 3.75 4.73 2.71 #> 2 [Q1;Q3] [0.45;2.50] [2.46;4.44] [3.44;5.30] [1.04;4.33] #> 1 [Min;Max] [-2.34;4.36] [-2.44;6.19] [-2.99;7.96] [-2.99;7.96] #> 5 Missing 4 4 2 10 #> #> ############################################ #>
# Quantitative statistics with two factors report.quanti(data=datafake,y="y_numeric",x1="GROUP",x2="TIMEPOINT")
#> #> ############################################ #> Quantitative descriptive statistics of: y_numeric #> ############################################ #> #> TIMEPOINT Statistics A B C #> 1 D0 N 30 20 16 #> 2 D0 Mean (SD) -0.93(0.86) -0.67(1.09) -1.19(0.92) #> 3 D0 Median -0.82 -0.69 -1.26 #> 4 D0 [Q1;Q3] [-1.59;-0.16] [-1.39;-0.06] [-1.62;-0.83] #> 5 D0 [Min;Max] [-2.34;0.36] [-2.44;2.10] [-2.99;0.66] #> 6 D0 Missing 1 1 0 #> 7 #> 8 D1 N 30 20 16 #> 9 D1 Mean (SD) 1.83(1.04) 4.17(1.28) 4.98(0.69) #> 10 D1 Median 1.78 4.19 5.08 #> 11 D1 [Q1;Q3] [ 0.94; 2.54] [ 3.23; 4.92] [ 4.58; 5.46] #> 12 D1 [Min;Max] [ 0.11;3.88] [ 1.48;6.19] [ 3.80;6.23] #> 13 D1 Missing 1 0 0 #> 14 #> 15 D2 N 30 20 16 #> 16 D2 Mean (SD) 1.97(1.17) 4.04(0.89) 4.90(1.36) #> 17 D2 Median 1.66 4.19 5.06 #> 18 D2 [Q1;Q3] [ 1.23; 2.86] [ 3.62; 4.36] [ 4.34; 5.20] #> 19 D2 [Min;Max] [-0.18;4.36] [ 2.03;5.63] [ 2.39;7.96] #> 20 D2 Missing 1 1 0 #> 21 #> 22 D3 N 30 20 16 #> 23 D3 Mean (SD) 1.78(1.17) 3.81(0.94) 5.07(1.12) #> 24 D3 Median 1.78 3.63 5.22 #> 25 D3 [Q1;Q3] [ 0.93; 2.42] [ 3.13; 4.44] [ 4.11; 5.66] #> 26 D3 [Min;Max] [-0.16;3.90] [ 2.46;6.01] [ 3.16;7.37] #> 27 D3 Missing 0 1 1 #> 28 #> 29 D4 N 30 20 16 #> 30 D4 Mean (SD) 1.83(0.85) 3.80(0.95) 5.17(1.03) #> 31 D4 Median 1.67 3.83 4.88 #> 32 D4 [Q1;Q3] [ 1.26; 2.32] [ 3.12; 4.42] [ 4.69; 5.50] #> 33 D4 [Min;Max] [ 0.38;3.97] [ 2.31;5.41] [ 3.24;6.96] #> 34 D4 Missing 1 1 1 #> 35 #> 36 D5 N 30 20 16 #> 37 D5 Mean (SD) 2.27(1.20) 3.64(1.19) 4.43(0.98) #> 38 D5 Median 2.50 3.86 4.57 #> 39 D5 [Q1;Q3] [ 1.77; 3.21] [ 2.59; 4.60] [ 3.44; 4.97] #> 40 D5 [Min;Max] [-1.19;4.31] [ 0.91;5.12] [ 2.95;6.54] #> 41 D5 Missing 0 0 0 #> #> ############################################ #>
# Quantitative statistics with two factors and a total column report.quanti(data=datafake,y="y_numeric",x1="GROUP",x2="TIMEPOINT",total=TRUE)
#> #> ############################################ #> Quantitative descriptive statistics of: y_numeric #> ############################################ #> #> TIMEPOINT Statistics A B C Total #> 1 D0 N 30 20 16 66 #> 2 D0 Mean (SD) -0.93(0.86) -0.67(1.09) -1.19(0.92) -0.92(0.95) #> 3 D0 Median -0.82 -0.69 -1.26 -0.86 #> 4 D0 [Q1;Q3] [-1.59;-0.16] [-1.39;-0.06] [-1.62;-0.83] [-1.55;-0.16] #> 5 D0 [Min;Max] [-2.34;0.36] [-2.44;2.10] [-2.99;0.66] [-2.99;2.10] #> 6 D0 Missing 1 1 0 2 #> 7 #> 8 D1 N 30 20 16 66 #> 9 D1 Mean (SD) 1.83(1.04) 4.17(1.28) 4.98(0.69) 3.33(1.73) #> 10 D1 Median 1.78 4.19 5.08 3.57 #> 11 D1 [Q1;Q3] [ 0.94; 2.54] [ 3.23; 4.92] [ 4.58; 5.46] [ 1.78; 4.91] #> 12 D1 [Min;Max] [ 0.11;3.88] [ 1.48;6.19] [ 3.80;6.23] [ 0.11;6.23] #> 13 D1 Missing 1 0 0 1 #> 14 #> 15 D2 N 30 20 16 66 #> 16 D2 Mean (SD) 1.97(1.17) 4.04(0.89) 4.90(1.36) 3.32(1.70) #> 17 D2 Median 1.66 4.19 5.06 3.57 #> 18 D2 [Q1;Q3] [ 1.23; 2.86] [ 3.62; 4.36] [ 4.34; 5.20] [ 1.89; 4.44] #> 19 D2 [Min;Max] [-0.18;4.36] [ 2.03;5.63] [ 2.39;7.96] [-0.18;7.96] #> 20 D2 Missing 1 1 0 2 #> 21 #> 22 D3 N 30 20 16 66 #> 23 D3 Mean (SD) 1.78(1.17) 3.81(0.94) 5.07(1.12) 3.15(1.75) #> 24 D3 Median 1.78 3.63 5.22 3.15 #> 25 D3 [Q1;Q3] [ 0.93; 2.42] [ 3.13; 4.44] [ 4.11; 5.66] [ 1.80; 4.39] #> 26 D3 [Min;Max] [-0.16;3.90] [ 2.46;6.01] [ 3.16;7.37] [-0.16;7.37] #> 27 D3 Missing 0 1 1 2 #> 28 #> 29 D4 N 30 20 16 66 #> 30 D4 Mean (SD) 1.83(0.85) 3.80(0.95) 5.17(1.03) 3.22(1.66) #> 31 D4 Median 1.67 3.83 4.88 3.16 #> 32 D4 [Q1;Q3] [ 1.26; 2.32] [ 3.12; 4.42] [ 4.69; 5.50] [ 1.69; 4.48] #> 33 D4 [Min;Max] [ 0.38;3.97] [ 2.31;5.41] [ 3.24;6.96] [ 0.38;6.96] #> 34 D4 Missing 1 1 1 3 #> 35 #> 36 D5 N 30 20 16 66 #> 37 D5 Mean (SD) 2.27(1.20) 3.64(1.19) 4.43(0.98) 3.21(1.45) #> 38 D5 Median 2.50 3.86 4.57 3.28 #> 39 D5 [Q1;Q3] [ 1.77; 3.21] [ 2.59; 4.60] [ 3.44; 4.97] [ 2.42; 4.44] #> 40 D5 [Min;Max] [-1.19;4.31] [ 0.91;5.12] [ 2.95;6.54] [-1.19;6.54] #> 41 D5 Missing 0 0 0 0 #> #> ############################################ #>
# Add median absolute deviance to the median statistics report.quanti(data=datafake,y="y_numeric",x1="GROUP",x2="TIMEPOINT",total=TRUE,add.mad=TRUE)
#> #> ############################################ #> Quantitative descriptive statistics of: y_numeric #> ############################################ #> #> TIMEPOINT Statistics A B C #> 1 D0 N 30 20 16 #> 2 D0 Mean (SD) -0.93(0.86) -0.67(1.09) -1.19(0.92) #> 3 D0 Median (MAD) -0.82(1.00) -0.69(0.97) -1.26(0.59) #> 4 D0 [Q1;Q3] [-1.59;-0.16] [-1.39;-0.06] [-1.62;-0.83] #> 5 D0 [Min;Max] [-2.34;0.36] [-2.44;2.10] [-2.99;0.66] #> 6 D0 Missing 1 1 0 #> 7 #> 8 D1 N 30 20 16 #> 9 D1 Mean (SD) 1.83(1.04) 4.17(1.28) 4.98(0.69) #> 10 D1 Median (MAD) 1.78(1.12) 4.19(1.25) 5.08(0.66) #> 11 D1 [Q1;Q3] [ 0.94; 2.54] [ 3.23; 4.92] [ 4.58; 5.46] #> 12 D1 [Min;Max] [ 0.11;3.88] [ 1.48;6.19] [ 3.80;6.23] #> 13 D1 Missing 1 0 0 #> 14 #> 15 D2 N 30 20 16 #> 16 D2 Mean (SD) 1.97(1.17) 4.04(0.89) 4.90(1.36) #> 17 D2 Median (MAD) 1.66(1.08) 4.19(0.50) 5.06(0.67) #> 18 D2 [Q1;Q3] [ 1.23; 2.86] [ 3.62; 4.36] [ 4.34; 5.20] #> 19 D2 [Min;Max] [-0.18;4.36] [ 2.03;5.63] [ 2.39;7.96] #> 20 D2 Missing 1 1 0 #> 21 #> 22 D3 N 30 20 16 #> 23 D3 Mean (SD) 1.78(1.17) 3.81(0.94) 5.07(1.12) #> 24 D3 Median (MAD) 1.78(1.23) 3.63(1.20) 5.22(1.25) #> 25 D3 [Q1;Q3] [ 0.93; 2.42] [ 3.13; 4.44] [ 4.11; 5.66] #> 26 D3 [Min;Max] [-0.16;3.90] [ 2.46;6.01] [ 3.16;7.37] #> 27 D3 Missing 0 1 1 #> 28 #> 29 D4 N 30 20 16 #> 30 D4 Mean (SD) 1.83(0.85) 3.80(0.95) 5.17(1.03) #> 31 D4 Median (MAD) 1.67(0.62) 3.83(0.96) 4.88(0.82) #> 32 D4 [Q1;Q3] [ 1.26; 2.32] [ 3.12; 4.42] [ 4.69; 5.50] #> 33 D4 [Min;Max] [ 0.38;3.97] [ 2.31;5.41] [ 3.24;6.96] #> 34 D4 Missing 1 1 1 #> 35 #> 36 D5 N 30 20 16 #> 37 D5 Mean (SD) 2.27(1.20) 3.64(1.19) 4.43(0.98) #> 38 D5 Median (MAD) 2.50(1.09) 3.86(1.18) 4.57(0.95) #> 39 D5 [Q1;Q3] [ 1.77; 3.21] [ 2.59; 4.60] [ 3.44; 4.97] #> 40 D5 [Min;Max] [-1.19;4.31] [ 0.91;5.12] [ 2.95;6.54] #> 41 D5 Missing 0 0 0 #> Total #> 1 66 #> 2 -0.92(0.95) #> 3 -0.86(1.03) #> 4 [-1.55;-0.16] #> 5 [-2.99;2.10] #> 6 2 #> 7 #> 8 66 #> 9 3.33(1.73) #> 10 3.57(2.14) #> 11 [ 1.78; 4.91] #> 12 [ 0.11;6.23] #> 13 1 #> 14 #> 15 66 #> 16 3.32(1.70) #> 17 3.57(1.89) #> 18 [ 1.89; 4.44] #> 19 [-0.18;7.96] #> 20 2 #> 21 #> 22 66 #> 23 3.15(1.75) #> 24 3.15(1.88) #> 25 [ 1.80; 4.39] #> 26 [-0.16;7.37] #> 27 2 #> 28 #> 29 66 #> 30 3.22(1.66) #> 31 3.16(2.14) #> 32 [ 1.69; 4.48] #> 33 [ 0.38;6.96] #> 34 3 #> 35 #> 36 66 #> 37 3.21(1.45) #> 38 3.28(1.48) #> 39 [ 2.42; 4.44] #> 40 [-1.19;6.54] #> 41 0 #> #> ############################################ #>
# Quantitative statistics with spacing rows (option at.row) report.quanti(data=datafake,y="y_numeric",x1="GROUP", x2="TIMEPOINT",total=TRUE,at.row="TIMEPOINT")
#> #> ############################################ #> Quantitative descriptive statistics of: y_numeric #> ############################################ #> #> TIMEPOINT Statistics A B C Total #> 1 D0 N 30 20 16 66 #> 2 D0 Mean (SD) -0.93(0.86) -0.67(1.09) -1.19(0.92) -0.92(0.95) #> 3 D0 Median -0.82 -0.69 -1.26 -0.86 #> 4 D0 [Q1;Q3] [-1.59;-0.16] [-1.39;-0.06] [-1.62;-0.83] [-1.55;-0.16] #> 5 D0 [Min;Max] [-2.34;0.36] [-2.44;2.10] [-2.99;0.66] [-2.99;2.10] #> 6 D0 Missing 1 1 0 2 #> 7 #> 8 D1 N 30 20 16 66 #> 9 D1 Mean (SD) 1.83(1.04) 4.17(1.28) 4.98(0.69) 3.33(1.73) #> 10 D1 Median 1.78 4.19 5.08 3.57 #> 11 D1 [Q1;Q3] [ 0.94; 2.54] [ 3.23; 4.92] [ 4.58; 5.46] [ 1.78; 4.91] #> 12 D1 [Min;Max] [ 0.11;3.88] [ 1.48;6.19] [ 3.80;6.23] [ 0.11;6.23] #> 13 D1 Missing 1 0 0 1 #> 14 #> 15 D2 N 30 20 16 66 #> 16 D2 Mean (SD) 1.97(1.17) 4.04(0.89) 4.90(1.36) 3.32(1.70) #> 17 D2 Median 1.66 4.19 5.06 3.57 #> 18 D2 [Q1;Q3] [ 1.23; 2.86] [ 3.62; 4.36] [ 4.34; 5.20] [ 1.89; 4.44] #> 19 D2 [Min;Max] [-0.18;4.36] [ 2.03;5.63] [ 2.39;7.96] [-0.18;7.96] #> 20 D2 Missing 1 1 0 2 #> 21 #> 22 D3 N 30 20 16 66 #> 23 D3 Mean (SD) 1.78(1.17) 3.81(0.94) 5.07(1.12) 3.15(1.75) #> 24 D3 Median 1.78 3.63 5.22 3.15 #> 25 D3 [Q1;Q3] [ 0.93; 2.42] [ 3.13; 4.44] [ 4.11; 5.66] [ 1.80; 4.39] #> 26 D3 [Min;Max] [-0.16;3.90] [ 2.46;6.01] [ 3.16;7.37] [-0.16;7.37] #> 27 D3 Missing 0 1 1 2 #> 28 #> 29 D4 N 30 20 16 66 #> 30 D4 Mean (SD) 1.83(0.85) 3.80(0.95) 5.17(1.03) 3.22(1.66) #> 31 D4 Median 1.67 3.83 4.88 3.16 #> 32 D4 [Q1;Q3] [ 1.26; 2.32] [ 3.12; 4.42] [ 4.69; 5.50] [ 1.69; 4.48] #> 33 D4 [Min;Max] [ 0.38;3.97] [ 2.31;5.41] [ 3.24;6.96] [ 0.38;6.96] #> 34 D4 Missing 1 1 1 3 #> 35 #> 36 D5 N 30 20 16 66 #> 37 D5 Mean (SD) 2.27(1.20) 3.64(1.19) 4.43(0.98) 3.21(1.45) #> 38 D5 Median 2.50 3.86 4.57 3.28 #> 39 D5 [Q1;Q3] [ 1.77; 3.21] [ 2.59; 4.60] [ 3.44; 4.97] [ 2.42; 4.44] #> 40 D5 [Min;Max] [-1.19;4.31] [ 0.91;5.12] [ 2.95;6.54] [-1.19;6.54] #> 41 D5 Missing 0 0 0 0 #> #> ############################################ #>
# Add number of subjects in headers (option subjid) tab=report.quanti(data=datafake,y="y_numeric",x1="GROUP", x2="TIMEPOINT",total=TRUE,at.row="TIMEPOINT",subjid="SUBJID") # Print tab output tab
#> #> ############################################ #> Quantitative descriptive statistics of: y_numeric #> ############################################ #> #> TIMEPOINT Statistics A (N=30) B (N=21) C (N=17) Total (N=68) #> 1 D0 N 30 20 16 66 #> 2 D0 Mean (SD) -0.93(0.86) -0.67(1.09) -1.19(0.92) -0.92(0.95) #> 3 D0 Median -0.82 -0.69 -1.26 -0.86 #> 4 D0 [Q1;Q3] [-1.59;-0.16] [-1.39;-0.06] [-1.62;-0.83] [-1.55;-0.16] #> 5 D0 [Min;Max] [-2.34;0.36] [-2.44;2.10] [-2.99;0.66] [-2.99;2.10] #> 6 D0 Missing 1 1 0 2 #> 7 #> 8 D1 N 30 20 16 66 #> 9 D1 Mean (SD) 1.83(1.04) 4.17(1.28) 4.98(0.69) 3.33(1.73) #> 10 D1 Median 1.78 4.19 5.08 3.57 #> 11 D1 [Q1;Q3] [ 0.94; 2.54] [ 3.23; 4.92] [ 4.58; 5.46] [ 1.78; 4.91] #> 12 D1 [Min;Max] [ 0.11;3.88] [ 1.48;6.19] [ 3.80;6.23] [ 0.11;6.23] #> 13 D1 Missing 1 0 0 1 #> 14 #> 15 D2 N 30 20 16 66 #> 16 D2 Mean (SD) 1.97(1.17) 4.04(0.89) 4.90(1.36) 3.32(1.70) #> 17 D2 Median 1.66 4.19 5.06 3.57 #> 18 D2 [Q1;Q3] [ 1.23; 2.86] [ 3.62; 4.36] [ 4.34; 5.20] [ 1.89; 4.44] #> 19 D2 [Min;Max] [-0.18;4.36] [ 2.03;5.63] [ 2.39;7.96] [-0.18;7.96] #> 20 D2 Missing 1 1 0 2 #> 21 #> 22 D3 N 30 20 16 66 #> 23 D3 Mean (SD) 1.78(1.17) 3.81(0.94) 5.07(1.12) 3.15(1.75) #> 24 D3 Median 1.78 3.63 5.22 3.15 #> 25 D3 [Q1;Q3] [ 0.93; 2.42] [ 3.13; 4.44] [ 4.11; 5.66] [ 1.80; 4.39] #> 26 D3 [Min;Max] [-0.16;3.90] [ 2.46;6.01] [ 3.16;7.37] [-0.16;7.37] #> 27 D3 Missing 0 1 1 2 #> 28 #> 29 D4 N 30 20 16 66 #> 30 D4 Mean (SD) 1.83(0.85) 3.80(0.95) 5.17(1.03) 3.22(1.66) #> 31 D4 Median 1.67 3.83 4.88 3.16 #> 32 D4 [Q1;Q3] [ 1.26; 2.32] [ 3.12; 4.42] [ 4.69; 5.50] [ 1.69; 4.48] #> 33 D4 [Min;Max] [ 0.38;3.97] [ 2.31;5.41] [ 3.24;6.96] [ 0.38;6.96] #> 34 D4 Missing 1 1 1 3 #> 35 #> 36 D5 N 30 20 16 66 #> 37 D5 Mean (SD) 2.27(1.20) 3.64(1.19) 4.43(0.98) 3.21(1.45) #> 38 D5 Median 2.50 3.86 4.57 3.28 #> 39 D5 [Q1;Q3] [ 1.77; 3.21] [ 2.59; 4.60] [ 3.44; 4.97] [ 2.42; 4.44] #> 40 D5 [Min;Max] [-1.19;4.31] [ 0.91;5.12] [ 2.95;6.54] [-1.19;6.54] #> 41 D5 Missing 0 0 0 0 #> #> ############################################ #>
#Getting a specific statistic and not the default ones mystat=function(x) quantile(x,0.99,na.rm=TRUE) tab=report.quanti(data=datafake,y="y_numeric",x1="GROUP", x2="TIMEPOINT",total=TRUE,subjid="SUBJID", func.stat=mystat,func.stat.name="99% quantile")
#> Error in mystat(y_numeric): impossible de trouver la fonction "mystat"
tab
#> #> ############################################ #> Quantitative descriptive statistics of: y_numeric #> ############################################ #> #> TIMEPOINT Statistics A (N=30) B (N=21) C (N=17) Total (N=68) #> 1 D0 N 30 20 16 66 #> 2 D0 Mean (SD) -0.93(0.86) -0.67(1.09) -1.19(0.92) -0.92(0.95) #> 3 D0 Median -0.82 -0.69 -1.26 -0.86 #> 4 D0 [Q1;Q3] [-1.59;-0.16] [-1.39;-0.06] [-1.62;-0.83] [-1.55;-0.16] #> 5 D0 [Min;Max] [-2.34;0.36] [-2.44;2.10] [-2.99;0.66] [-2.99;2.10] #> 6 D0 Missing 1 1 0 2 #> 7 #> 8 D1 N 30 20 16 66 #> 9 D1 Mean (SD) 1.83(1.04) 4.17(1.28) 4.98(0.69) 3.33(1.73) #> 10 D1 Median 1.78 4.19 5.08 3.57 #> 11 D1 [Q1;Q3] [ 0.94; 2.54] [ 3.23; 4.92] [ 4.58; 5.46] [ 1.78; 4.91] #> 12 D1 [Min;Max] [ 0.11;3.88] [ 1.48;6.19] [ 3.80;6.23] [ 0.11;6.23] #> 13 D1 Missing 1 0 0 1 #> 14 #> 15 D2 N 30 20 16 66 #> 16 D2 Mean (SD) 1.97(1.17) 4.04(0.89) 4.90(1.36) 3.32(1.70) #> 17 D2 Median 1.66 4.19 5.06 3.57 #> 18 D2 [Q1;Q3] [ 1.23; 2.86] [ 3.62; 4.36] [ 4.34; 5.20] [ 1.89; 4.44] #> 19 D2 [Min;Max] [-0.18;4.36] [ 2.03;5.63] [ 2.39;7.96] [-0.18;7.96] #> 20 D2 Missing 1 1 0 2 #> 21 #> 22 D3 N 30 20 16 66 #> 23 D3 Mean (SD) 1.78(1.17) 3.81(0.94) 5.07(1.12) 3.15(1.75) #> 24 D3 Median 1.78 3.63 5.22 3.15 #> 25 D3 [Q1;Q3] [ 0.93; 2.42] [ 3.13; 4.44] [ 4.11; 5.66] [ 1.80; 4.39] #> 26 D3 [Min;Max] [-0.16;3.90] [ 2.46;6.01] [ 3.16;7.37] [-0.16;7.37] #> 27 D3 Missing 0 1 1 2 #> 28 #> 29 D4 N 30 20 16 66 #> 30 D4 Mean (SD) 1.83(0.85) 3.80(0.95) 5.17(1.03) 3.22(1.66) #> 31 D4 Median 1.67 3.83 4.88 3.16 #> 32 D4 [Q1;Q3] [ 1.26; 2.32] [ 3.12; 4.42] [ 4.69; 5.50] [ 1.69; 4.48] #> 33 D4 [Min;Max] [ 0.38;3.97] [ 2.31;5.41] [ 3.24;6.96] [ 0.38;6.96] #> 34 D4 Missing 1 1 1 3 #> 35 #> 36 D5 N 30 20 16 66 #> 37 D5 Mean (SD) 2.27(1.20) 3.64(1.19) 4.43(0.98) 3.21(1.45) #> 38 D5 Median 2.50 3.86 4.57 3.28 #> 39 D5 [Q1;Q3] [ 1.77; 3.21] [ 2.59; 4.60] [ 3.44; 4.97] [ 2.42; 4.44] #> 40 D5 [Min;Max] [-1.19;4.31] [ 0.91;5.12] [ 2.95;6.54] [-1.19;6.54] #> 41 D5 Missing 0 0 0 0 #> #> ############################################ #>
mystat2=function(x) mean(x,na.rm=TRUE)/sd(x,na.rm=TRUE) tab=report.quanti(data=datafake,y="y_numeric",x1="GROUP", total=TRUE,subjid="SUBJID",func.stat=mystat2, func.stat.name="Coefficient of variation")
#> Error in mystat2(y_numeric): impossible de trouver la fonction "mystat2"
tab
#> #> ############################################ #> Quantitative descriptive statistics of: y_numeric #> ############################################ #> #> TIMEPOINT Statistics A (N=30) B (N=21) C (N=17) Total (N=68) #> 1 D0 N 30 20 16 66 #> 2 D0 Mean (SD) -0.93(0.86) -0.67(1.09) -1.19(0.92) -0.92(0.95) #> 3 D0 Median -0.82 -0.69 -1.26 -0.86 #> 4 D0 [Q1;Q3] [-1.59;-0.16] [-1.39;-0.06] [-1.62;-0.83] [-1.55;-0.16] #> 5 D0 [Min;Max] [-2.34;0.36] [-2.44;2.10] [-2.99;0.66] [-2.99;2.10] #> 6 D0 Missing 1 1 0 2 #> 7 #> 8 D1 N 30 20 16 66 #> 9 D1 Mean (SD) 1.83(1.04) 4.17(1.28) 4.98(0.69) 3.33(1.73) #> 10 D1 Median 1.78 4.19 5.08 3.57 #> 11 D1 [Q1;Q3] [ 0.94; 2.54] [ 3.23; 4.92] [ 4.58; 5.46] [ 1.78; 4.91] #> 12 D1 [Min;Max] [ 0.11;3.88] [ 1.48;6.19] [ 3.80;6.23] [ 0.11;6.23] #> 13 D1 Missing 1 0 0 1 #> 14 #> 15 D2 N 30 20 16 66 #> 16 D2 Mean (SD) 1.97(1.17) 4.04(0.89) 4.90(1.36) 3.32(1.70) #> 17 D2 Median 1.66 4.19 5.06 3.57 #> 18 D2 [Q1;Q3] [ 1.23; 2.86] [ 3.62; 4.36] [ 4.34; 5.20] [ 1.89; 4.44] #> 19 D2 [Min;Max] [-0.18;4.36] [ 2.03;5.63] [ 2.39;7.96] [-0.18;7.96] #> 20 D2 Missing 1 1 0 2 #> 21 #> 22 D3 N 30 20 16 66 #> 23 D3 Mean (SD) 1.78(1.17) 3.81(0.94) 5.07(1.12) 3.15(1.75) #> 24 D3 Median 1.78 3.63 5.22 3.15 #> 25 D3 [Q1;Q3] [ 0.93; 2.42] [ 3.13; 4.44] [ 4.11; 5.66] [ 1.80; 4.39] #> 26 D3 [Min;Max] [-0.16;3.90] [ 2.46;6.01] [ 3.16;7.37] [-0.16;7.37] #> 27 D3 Missing 0 1 1 2 #> 28 #> 29 D4 N 30 20 16 66 #> 30 D4 Mean (SD) 1.83(0.85) 3.80(0.95) 5.17(1.03) 3.22(1.66) #> 31 D4 Median 1.67 3.83 4.88 3.16 #> 32 D4 [Q1;Q3] [ 1.26; 2.32] [ 3.12; 4.42] [ 4.69; 5.50] [ 1.69; 4.48] #> 33 D4 [Min;Max] [ 0.38;3.97] [ 2.31;5.41] [ 3.24;6.96] [ 0.38;6.96] #> 34 D4 Missing 1 1 1 3 #> 35 #> 36 D5 N 30 20 16 66 #> 37 D5 Mean (SD) 2.27(1.20) 3.64(1.19) 4.43(0.98) 3.21(1.45) #> 38 D5 Median 2.50 3.86 4.57 3.28 #> 39 D5 [Q1;Q3] [ 1.77; 3.21] [ 2.59; 4.60] [ 3.44; 4.97] [ 2.42; 4.44] #> 40 D5 [Min;Max] [-1.19;4.31] [ 0.91;5.12] [ 2.95;6.54] [-1.19;6.54] #> 41 D5 Missing 0 0 0 0 #> #> ############################################ #>
mode=function(x) { x=na.omit(x) ux <- unique(x) ux[which.max(tabulate(match(x, ux)))] } tab=report.quanti(data=datafake,y="y_numeric", func.stat=mode,func.stat.name="Mode") #Getting raw output tab$raw.output
#> y_numeric #> 1 numeric
#Getting a data.frame version of the output tab$output
#> Statistics y_numeric #> 1 Mode numeric