Giter VIP home page Giter VIP logo

Comments (3)

ian-adams avatar ian-adams commented on July 18, 2024 1

Full local function to fix this error @(mgclaros)

predict_h_index <- function(id, journals = NULL) {
    id <- tidy_id(id)

    # Getting the h-index and checking for NA
    h <- get_profile(id)$h_index
    if (is.na(h)) return(NA)

    n <- get_num_articles(id) # number of articles written
    y <- as.numeric(format(Sys.Date(), "%Y")) - get_oldest_article(id)
    j <- get_num_distinct_journals(id)

    # Handle optional journals parameter
    if (is.null(journals)) {
        q <- get_num_top_journals(id)
    } else {
        q <- get_num_top_journals(id, journals)
    }

    # Regression coefficients
    coefs <- c(
        1, 0.760, 0.373, 0.967, -0.069, 0.018, 0.033,
        2, 1.413, 0.781, 0.936, -0.132, 0.018, 0.064,
        3, 2.227, 1.105, 0.903, -0.193, 0.027, 0.096,
        4, 3.196, 1.386, 0.871, -0.274, 0.039, 0.145,
        5, 3.997, 1.578, 0.858, -0.345, 0.063, 0.198,
        6, 4.752, 1.671, 0.817, -0.377, 0.117, 0.282,
        7, 5.741, 1.761, 0.761, -0.420, 0.170, 0.394,
        8, 6.531, 1.796, 0.669, -0.420, 0.252, 0.508,
        9, 7.482, 1.653, 0.561, -0.415, 0.383, 0.629,
        10, 8.734, 1.326, 0.478, -0.411, 0.522, 0.823
    )
    coefs.m <- matrix(coefs, nrow=10, byrow=TRUE)
    coefs <- coefs.m[,-1]
    vals <- c(1, sqrt(n), h, y, j, q)

    # Calculate the h-index predictions
    h.pred <- coefs %*% vals
    h.vals <- c(h, h.pred)

    # Check for sensible values
    standard.warning <- "You're probably not a neuroscientist. Please read the documentation for information on the limitations of this function."
  
    if (any(diff(h.vals) < 0)) {
        warning(paste0("Decreasing h-values predicted. ", standard.warning))
    }

    if (any(h.vals < 0)) {
        warning(paste0("Negative h-values predicted. ", standard.warning))
    }
  
    return(data.frame(years_ahead = 0:10, h_index = h.vals))
}

from scholar.

bappa10085 avatar bappa10085 commented on July 18, 2024

Installing the development version solves the error like

remotes::install_github("jkeirstead/scholar")

from scholar.

mgclaros avatar mgclaros commented on July 18, 2024

The development version did not function, but the 'alternative' the function worked fine :-) Thanks!

from scholar.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.