conig / corx

corx: Create and Format Correlation Matrices
Other
4 stars 0 forks source link

describe: n() function #5

Closed drpedapati closed 3 years ago

drpedapati commented 3 years ago

continue to enjoy this package. I've been trying to figure out a way to to show an 'n' column but stuck so far. could you implement an n() function so the describe= column could list the number of values included in the correlation (subtracting for NAs)? Thanks

conig commented 3 years ago

Thanks for the suggestion, this should be working in devel now.

library(corx)

mtcars$cyl[4] = NA

corx(mtcars[1:5],
     triangle = "lower",
     describe = c(N = "n"))
#> corx(data = mtcars[1:5], triangle = "lower", describe = c(N = "n"))
#> 
#> -----------------------------------------
#>               1       2       3      4  N
#> -----------------------------------------
#> 1. mpg       -                         32
#> 2. cyl  -.85***      -                 31
#> 3. disp -.85***  .90***      -         32
#> 4. hp   -.78***  .83***  .79***     -  32
#> 5. drat  .68*** -.71*** -.71*** -.45** 32
#> -----------------------------------------
#> Note. * p < 0.05; ** p < 0.01; *** p < 0.001