Skip to contents

1. Respect Rate Limits

Even with built-in rate limiting, be considerate when making requests:

# Good practice: Add additional delays between scholar extractions
scholar_ids <- c("id1", "id2", "id3")
results <- list()

for (id in scholar_ids) {
    results[[id]] <- ExtractScholarData(id, max_publications = 20)
    Sys.sleep(10)  # Additional delay between scholars
}

2. Data Caching

Cache results to avoid repeated requests:

# Check if cached data exists
cache_file <- "scholar_cache.rds"
if (file.exists(cache_file)) {
    cached_data <- readRDS(cache_file)
} else {
    # Extract and cache data
    cached_data <- ExtractScholarData("qc6CJjYAAAAJ", max_publications = 50)
    saveRDS(cached_data, cache_file)
}

3. Error Handling

Use try-catch blocks for robust analysis:

safe_extract <- function(scholar_id) {
    tryCatch({
        ExtractScholarData(scholar_id, max_publications = 20)
    }, error = function(e) {
        warning(sprintf("Failed to extract data for %s: %s", scholar_id, 
                        e$message))
        NULL
    })
}

Session Information