easystats / correlation

:link: Methods for Correlation Analysis
https://easystats.github.io/correlation/
Other
435 stars 56 forks source link

subsetting rows and cols in cormatrix removes significance stars #26

Open DominiqueMakowski opened 5 years ago

DominiqueMakowski commented 5 years ago
x <- as.table(correlation(iris))
x
x[1:3, 1:3]

And this is because subsetting a dataframe removes all attributes for some reason (which I didn't know). I am not sure if they are any easy workarounds.

strengejacke commented 4 years ago

You can define your own resp. overwrite the [ <-] method, and then save the attributes. I did this once for parameters, so you can do something like parameters(...)[1:4] for printing, but this messed up some other stuff (I can't remember) so I removed it again...

bwiernik commented 3 years ago

Here is an exampe [ method for a complex S3 class https://github.com/psychmeta/psychmeta/blob/fb6816579db4f0878c5586520268ec38edee15a1/R/methods_dplyr_ma_psychmeta.R#L289