R/price.R

ok.bibliometrics.price <- function(authors.vector, sep=';') {
  res <- list()
  res$authors.vector <- strsplit(authors.vector, sep) %>% unlist()
  res$authors.table <- table(res$authors.vector) %>% sort(T)
  res$table.of.table <- table(res$authors.table)
  authors.list <- strsplit(authors.vector, sep)

  # res$cutoff <- round(length(res$authors.table)/10)
  # res$cutoff_productivity <- res$authors.table[res$cutoff]
  # res$top10perc.authors <- names(res$authors.table)[1:res$cutoff]

  res$theoretical.cutoff.ind <- round(length(res$authors.table)/10)
  res$cutoff <- ifelse(unname(res$authors.table[res$theoretical.cutoff.ind])!=unname(res$authors.table[res$theoretical.cutoff.ind+1]), res$theoretical.cutoff.ind, which(res$authors.table == res$authors.table[res$theoretical.cutoff.ind])[1]-1)
  res$cutoff_productivity <- res$authors.table[res$cutoff]
  res$top10perc.authors <- names(res$authors.table)[1:res$cutoff]
  res$real.share <- length(res$top10perc.authors) / length(res$authors.table)

  res$second.elite.idealSize <- res$authors.table %>% length() %>% sqrt() %>% round()
  #res$second.elite.realSize <- ifelse(unname(res$authors.table[res$second.elite.idealSize])!=unname(res$authors.table[res$second.elite.idealSize+1]), res$second.elite.idealSize, which(res$authors.table == res$authors.table[res$second.elite.idealSize])[1]-1)
  res$second.elite.realSize <- ifelse(unname(res$authors.table[res$second.elite.idealSize])!=unname(res$authors.table[res$second.elite.idealSize+1]), res$second.elite.idealSize, tail(which(res$authors.table == res$authors.table[res$second.elite.idealSize])))
  res$second.elite.names <- names(res$authors.table)[1:res$second.elite.realSize]
  res$second.elite.real.share <- res$second.elite.realSize / res$second.elite.idealSize
  res$second.elite.coauthored <- sum(sapply(authors.list, function(e){return(any(e%in%res$second.elite.names))})) / length(authors.vector)
  res$second.elite.allauthored <- sum(sapply(authors.list, function(e){return(all(e%in%res$second.elite.names))})) / length(authors.vector)
  res$second.elite.percSize <- res$second.elite.realSize / length(res$authors.table)
  res$second.elite.cutoffLevel <- res$authors.table[res$second.elite.realSize]

  partial <- sapply(authors.list, function(e){return(any(e%in%res$top10perc.authors))})
  all <- sapply(authors.list, function(e){return(all(e%in%res$top10perc.authors))})
  res$co.authored.10perc <- sum(partial) / length(authors.vector)
  res$all.authored.10perc <- sum(all) / length(authors.vector)
  return(res)
}

ok.bibliometrics.giants <- function(records) {
  giants <- Reduce(intersect, list(records$laws$price.count$second.elite.names,records$laws$price.cited$second.elite.names,records$laws$price.cited.filt$second.elite.names, records$laws$price.links$second.elite.names, records$laws$price.links.filt$second.elite.names))
  return(giants)
}
theogrost/bibliometricLaws documentation built on July 2, 2019, 8:56 p.m.