Skip to contents

This function returns a formatted character of correlation statistics.

Usage

cor_text(x, show_ci = TRUE, show_statistic = TRUE, show_sig = TRUE, ...)

Arguments

x

A dataframe with correlation statistics.

show_ci, show_statistic, show_sig

Toggle on/off different parts of the text.

...

Other arguments to be passed to or from other functions.

Examples

rez <- cor_test(mtcars, "mpg", "wt")

cor_text(rez)
#> [1] "r = -0.87, 95% CI [-0.93, -0.74], t(30) = -9.56, p < .001"
cor_text(rez, show_statistic = FALSE, show_ci = FALSE, stars = TRUE)
#> [1] "r = -0.87, p < .001***"

rez <- correlation(mtcars)

cor_text(rez)
#>  [1] "r = -0.85, 95% CI [-0.93, -0.72], t(30) = -8.92, p < .001" 
#>  [2] "r = -0.85, 95% CI [-0.92, -0.71], t(30) = -8.75, p < .001" 
#>  [3] "r = -0.78, 95% CI [-0.89, -0.59], t(30) = -6.74, p < .001" 
#>  [4] "r = 0.68, 95% CI [0.44, 0.83], t(30) = 5.10, p < .001"     
#>  [5] "r = -0.87, 95% CI [-0.93, -0.74], t(30) = -9.56, p < .001" 
#>  [6] "r = 0.42, 95% CI [0.08, 0.67], t(30) = 2.53, p = 0.222"    
#>  [7] "r = 0.66, 95% CI [0.41, 0.82], t(30) = 4.86, p = 0.001"    
#>  [8] "r = 0.60, 95% CI [0.32, 0.78], t(30) = 4.11, p = 0.008"    
#>  [9] "r = 0.48, 95% CI [0.16, 0.71], t(30) = 3.00, p = 0.097"    
#> [10] "r = -0.55, 95% CI [-0.75, -0.25], t(30) = -3.62, p = 0.024"
#> [11] "r = 0.90, 95% CI [0.81, 0.95], t(30) = 11.45, p < .001"    
#> [12] "r = 0.83, 95% CI [0.68, 0.92], t(30) = 8.23, p < .001"     
#> [13] "r = -0.70, 95% CI [-0.84, -0.46], t(30) = -5.37, p < .001" 
#> [14] "r = 0.78, 95% CI [0.60, 0.89], t(30) = 6.88, p < .001"     
#> [15] "r = -0.59, 95% CI [-0.78, -0.31], t(30) = -4.02, p = 0.010"
#> [16] "r = -0.81, 95% CI [-0.90, -0.64], t(30) = -7.59, p < .001" 
#> [17] "r = -0.52, 95% CI [-0.74, -0.21], t(30) = -3.36, p = 0.043"
#> [18] "r = -0.49, 95% CI [-0.72, -0.17], t(30) = -3.10, p = 0.079"
#> [19] "r = 0.53, 95% CI [0.22, 0.74], t(30) = 3.40, p = 0.041"    
#> [20] "r = 0.79, 95% CI [0.61, 0.89], t(30) = 7.08, p < .001"     
#> [21] "r = -0.71, 95% CI [-0.85, -0.48], t(30) = -5.53, p < .001" 
#> [22] "r = 0.89, 95% CI [0.78, 0.94], t(30) = 10.58, p < .001"    
#> [23] "r = -0.43, 95% CI [-0.68, -0.10], t(30) = -2.64, p = 0.197"
#> [24] "r = -0.71, 95% CI [-0.85, -0.48], t(30) = -5.53, p < .001" 
#> [25] "r = -0.59, 95% CI [-0.78, -0.31], t(30) = -4.02, p = 0.010"
#> [26] "r = -0.56, 95% CI [-0.76, -0.26], t(30) = -3.66, p = 0.023"
#> [27] "r = 0.39, 95% CI [0.05, 0.65], t(30) = 2.35, p = 0.303"    
#> [28] "r = -0.45, 95% CI [-0.69, -0.12], t(30) = -2.75, p = 0.170"
#> [29] "r = 0.66, 95% CI [0.40, 0.82], t(30) = 4.80, p = 0.001"    
#> [30] "r = -0.71, 95% CI [-0.85, -0.48], t(30) = -5.49, p < .001" 
#> [31] "r = -0.72, 95% CI [-0.86, -0.50], t(30) = -5.73, p < .001" 
#> [32] "r = -0.24, 95% CI [-0.55, 0.12], t(30) = -1.37, p > .999"  
#> [33] "r = -0.13, 95% CI [-0.45, 0.23], t(30) = -0.69, p > .999"  
#> [34] "r = 0.75, 95% CI [0.54, 0.87], t(30) = 6.21, p < .001"     
#> [35] "r = -0.71, 95% CI [-0.85, -0.48], t(30) = -5.56, p < .001" 
#> [36] "r = 0.09, 95% CI [-0.27, 0.43], t(30) = 0.50, p > .999"    
#> [37] "r = 0.44, 95% CI [0.11, 0.68], t(30) = 2.69, p = 0.187"    
#> [38] "r = 0.71, 95% CI [0.48, 0.85], t(30) = 5.57, p < .001"     
#> [39] "r = 0.70, 95% CI [0.46, 0.84], t(30) = 5.36, p < .001"     
#> [40] "r = -0.09, 95% CI [-0.43, 0.27], t(30) = -0.50, p > .999"  
#> [41] "r = -0.17, 95% CI [-0.49, 0.19], t(30) = -0.97, p > .999"  
#> [42] "r = -0.55, 95% CI [-0.76, -0.26], t(30) = -3.65, p = 0.023"
#> [43] "r = -0.69, 95% CI [-0.84, -0.45], t(30) = -5.26, p < .001" 
#> [44] "r = -0.58, 95% CI [-0.77, -0.29], t(30) = -3.93, p = 0.012"
#> [45] "r = 0.43, 95% CI [0.09, 0.68], t(30) = 2.59, p = 0.205"    
#> [46] "r = 0.74, 95% CI [0.53, 0.87], t(30) = 6.11, p < .001"     
#> [47] "r = -0.23, 95% CI [-0.54, 0.13], t(30) = -1.29, p > .999"  
#> [48] "r = -0.21, 95% CI [-0.52, 0.15], t(30) = -1.19, p > .999"  
#> [49] "r = -0.66, 95% CI [-0.82, -0.40], t(30) = -4.76, p = 0.001"
#> [50] "r = 0.17, 95% CI [-0.19, 0.49], t(30) = 0.94, p > .999"    
#> [51] "r = 0.21, 95% CI [-0.15, 0.52], t(30) = 1.15, p > .999"    
#> [52] "r = -0.57, 95% CI [-0.77, -0.28], t(30) = -3.80, p = 0.017"
#> [53] "r = 0.79, 95% CI [0.62, 0.89], t(30) = 7.16, p < .001"     
#> [54] "r = 0.06, 95% CI [-0.30, 0.40], t(30) = 0.32, p > .999"    
#> [55] "r = 0.27, 95% CI [-0.08, 0.57], t(30) = 1.56, p > .999"