ProjectMOSAIC / mosaic

Project MOSAIC R package
http://mosaic-web.org/
93 stars 26 forks source link

change names of objects returned by count(), prop(), and perc()? #697

Closed rpruim closed 6 years ago

rpruim commented 6 years ago

This is a potentially breaking change (if people were relying on the names of the result for subsequent code). But it results in clearer labels and is more like how things work with df_stats()

perc(~sex, data = KidsFeet)
##   perc_B 
## 51.28205 
prop(~sex, data = KidsFeet)
##    prop_B 
## 0.5128205 
count(~sex, data = KidsFeet)
## n_B 
##  20 
rpruim commented 6 years ago

I've pushed this to beta and master. It is easily reverted if we don't like it (just remove two lines where the renaming happens).

rpruim commented 6 years ago

This propagates through df_stats() now too:

df_stats(~substance | sex, data = mosaicData::HELPmiss, prop)
##      sex prop_alcohol
## 1   male        0.412
## 2 female        0.333
df_stats(~substance | sex, data = mosaicData::HELPmiss, prop(success = "cocaine"))
##      sex prop_cocaine
## 1   male        0.320
## 2 female        0.369
df_stats(~substance | sex, data = mosaicData::HELPmiss, prop, props)
##      sex prop_alcohol prop_alcohol prop_cocaine prop_heroin prop_missing
## 1   male        0.412        0.412        0.320       0.267      0.00000
## 2 female        0.333        0.333        0.369       0.288      0.00901