Summarize count (and percent) of rows with exactly (and at least) N cols >= various thresholds
Source:R/colcounter_xyz.R
colcounter_summary_all.Rd
This wraps 4 functions to return 4 tables:
using colcounter_summary()
, colcounter_summary_pct()
,
colcounter_summary_cum()
, colcounter_summary_cum_pct()
For another view and text explanations of the findings, see
count_sites_with_n_high_scores()
See also
colcounter_summary_all()
colcounter_summary()
colcounter_summary_cum()
colcounter_summary_pct()
colcounter_summary_cum_pct()
Examples
# df <- bg22[ , names.ej.pctile]
df <- data.frame(a=rep(80,4),b=rep(93,4), col3=c(49,98,100,100))
bench <- 5 * (0:20)
a3 <- colcounter_summary_all(df, bench)
a3[,'95',]
a3[,,'cum_pct']
a3['0',,]; a3[1,,]
a3[dim(a3)[1],,]
# a3['12',,]; a3[13,,]
if (FALSE) { # \dontrun{
barplot(colcounter_summary_cum_pct(pdata, pcuts)[ , '80'],
ylab='% of places', xlab='# of indicators at/above threshold',
main='% of places with at least N/13 indicators >=80th percentile')
barplot(colcounter_summary(pdata, pcuts)[2:13 , '95'],
ylab='# of places', xlab='# of indicators at/above threshold',
main='# of places with exactly N/13 indicators >=95th percentile')
# pdata <- ejscreen package file bg22[ , names.e.pctile]
colcounter_summary_cum_pct(pdata,c(50,80,90,95))
xs <- 1:13
plot(x=xs, y=colcounter_summary_cum_pct(pdata, 50)[xs+1],
type='b', col='gray', ylim=c(0, 100),
main='% of places with at least x/13 indicators >=Nth percentile',
ylab='% of places', xlab='# of indicators')
points(xs, colcounter_summary_cum_pct(pdata, 80)[xs+1], type='b', col='blue')
points(xs, colcounter_summary_cum_pct(pdata, 90)[xs+1], type='b', col='orange')
points(xs, colcounter_summary_cum_pct(pdata, 95)[xs+1], type='b', col='red')
legend(x = 'topright', legend = paste0('>= ', c(50, 80, 90, 95),'th percentile'),
fill = c('gray', 'blue', 'orange', 'red'))
# pdata <- bg22[ , names.ej.pctile]
colcounter_summary_cum_pct(pdata,c(50,80,90,95))
xs <- 1:13
plot(x=xs, y=colcounter_summary_cum_pct(pdata, 50)[xs+1],
type='b', col='gray', ylim=c(0, 40),
main='% of places with at least x/13 indicators >=Nth percentile', ylab='% of places',
xlab='# of indicators')
points(xs, colcounter_summary_cum_pct(pdata, 80)[xs+1], type='b', col='blue')
points(xs, colcounter_summary_cum_pct(pdata, 90)[xs+1], type='b', col='orange')
points(xs, colcounter_summary_cum_pct(pdata, 95)[xs+1], type='b', col='red')
legend(x = 'topright', legend = paste0('>= ', c(50, 80, 90, 95),'th percentile'),
fill = c('gray', 'blue', 'orange', 'red'))
} # }