rm(list = ls())
## For information retrieval
library(scholar)
## Warning: package 'scholar' was built under R version 4.0.5
## For data manipulation
library(plyr)
## For plotting
library(ggplot2)
## My ID
kaz_yos <- "xrY7bFYAAAAJ"

## Retrieve data
df <- compare_scholar_careers(kaz_yos)
#View(df)
sum(df$cites)
## [1] 1200
head(df)
##             id year cites career_year        name
## 1 xrY7bFYAAAAJ 2007     5           0 Andi Fugard
## 2 xrY7bFYAAAAJ 2008     3           1 Andi Fugard
## 3 xrY7bFYAAAAJ 2009     3           2 Andi Fugard
## 4 xrY7bFYAAAAJ 2010     3           3 Andi Fugard
## 5 xrY7bFYAAAAJ 2011    10           4 Andi Fugard
## 6 xrY7bFYAAAAJ 2012    19           5 Andi Fugard
## Add cumulative citation
df <- ddply(.data = df,
            .variables = c("id"),
            .fun = transform,
            cumulative_cites = cumsum(cites))

## Plot
ggplot(df,
       mapping = aes(x = career_year, y = cumulative_cites, color = name)) +
  geom_line() +
  theme_bw()

###########################################
andi_id <- "xrY7bFYAAAAJ"
pubs <- get_publications(andi_id)
head(pubs,2)
##                                                                            title
## 1 Supporting thinking on sample sizes for thematic analyses: a quantitative tool
## 2        How people interpret conditionals: Shifts toward the conditional event.
##                                            author
## 1                           AJB Fugard, HWW Potts
## 2 AJB Fugard, N Pfeifer, B Mayerhofer, GD Kleiter
##                                                               journal
## 1                International Journal of Social Research Methodology
## 2 Journal of Experimental Psychology: Learning, Memory, and Cognition
##            number cites year                  cid        pubid
## 1 18 (6), 669-684   517 2015  3882549739737596858 PaBasH6fAo0C
## 2     37 (3), 635   128 2011 12907758729282933491 u-x6o8ySG0sC
#View(pubs)
current_year <- as.numeric(format(Sys.Date(), "%Y"))
current_year
## [1] 2021
#ref https://rpubs.com/kaz_yos/scholar_ky
#ref https://inductivestep.github.io/Google-scholar-in-R/