I was having issues with extracting author h-indices from Scopus. multi_author_retrieval was not working, so I created a loop with author_retrieval as a work around. After loading appropriate libraries...
`datareal <- read_excel("AuthorIDinfo.xlsx")
v2 <- datareal$last_author_id # THIS IS YOUR SCOPUS AUTHOR ID COLUMN
--- Define my_author_ids CORRECTLY from v2 (Scopus Author IDs) ---
my_author_ids <- unique(v2) # Get unique Scopus Author IDs
my_author_ids <- my_author_ids[!is.na(my_author_ids)] # Remove any NA values
my_author_ids <- as.character(my_author_ids) # Ensure they are character type
cat("\nStarting Scopus API data retrieval...\n")
cat("Total unique authors to process (after removing NAs):", length(my_author_ids), "\n") # Removing NAs because 'author_retrieval' stopped working with NAs
h_lst <- list() #Loop to individually pull h-index from each author
for (i in 1:length(my_author_ids)) {
author_data <- author_retrieval(au_id = as.numeric(my_author_ids[i]), view = "METRICS") #Data needed to be numeric for loop to work
h_index <- author_data$content$author-retrieval-response[[1]]$h-index
print(h_index)
if (is.null(h_index)) {
h_lst[[i]] <- 0
} else {
h_lst[[i]] <- h_index
}
}
as.vector(unlist(h_lst)) #to export data as table with "author id" and "h-index" columns
h_df <- data.frame(
author_id = my_author_ids,
h_index = unlist(h_lst)
)
write_xlsx(h_df,"AuthorIDhindex.xlsx")`
I think this is a great way to pull a large amount of author info in one go. Specifying one variable instead of all available author info is also convenient.
I was having issues with extracting author h-indices from Scopus.
multi_author_retrievalwas not working, so I created a loop withauthor_retrievalas a work around. After loading appropriate libraries...`datareal <- read_excel("AuthorIDinfo.xlsx")
v2 <- datareal$last_author_id # THIS IS YOUR SCOPUS AUTHOR ID COLUMN
--- Define my_author_ids CORRECTLY from v2 (Scopus Author IDs) ---
my_author_ids <- unique(v2) # Get unique Scopus Author IDs
my_author_ids <- my_author_ids[!is.na(my_author_ids)] # Remove any NA values
my_author_ids <- as.character(my_author_ids) # Ensure they are character type
cat("\nStarting Scopus API data retrieval...\n")
cat("Total unique authors to process (after removing NAs):", length(my_author_ids), "\n") # Removing NAs because 'author_retrieval' stopped working with NAs
h_lst <- list() #Loop to individually pull h-index from each author
for (i in 1:length(my_author_ids)) {
author_data <- author_retrieval(au_id = as.numeric(my_author_ids[i]), view = "METRICS") #Data needed to be numeric for loop to work
h_index <- author_data$content$
author-retrieval-response[[1]]$h-indexprint(h_index)
if (is.null(h_index)) {
h_lst[[i]] <- 0
} else {
h_lst[[i]] <- h_index
}
}
as.vector(unlist(h_lst)) #to export data as table with "author id" and "h-index" columns
h_df <- data.frame(
author_id = my_author_ids,
h_index = unlist(h_lst)
)
write_xlsx(h_df,"AuthorIDhindex.xlsx")`
I think this is a great way to pull a large amount of author info in one go. Specifying one variable instead of all available author info is also convenient.