Skip to contents

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()

Usage

colcounter_summary_all(x, thresholdlist, ...)

Arguments

x

Data.frame or matrix of numbers to be compared to threshold value, like percentiles for example.

thresholdlist

vector of numeric threshold values to compare to

...

passed to the 4 functions like or.tied=TRUE, na.rm=TRUE, below=FALSE, one.cut.per.col=FALSE

Value

A table of cumulative frequency counts etc., including count, cum, pct, 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'))
} # }