---
title: "Introduction to `MDPIexploreR`"
output: rmarkdown::html_vignette
vignette: >
  %\VignetteIndexEntry{Introduction to `MDPIexploreR`}
  %\VignetteEngine{knitr::rmarkdown}
  %\VignetteEncoding{UTF-8}
---

```{r, include = FALSE}
knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>"
)
```

```{r setup}
library(MDPIexploreR)
```

Welcome to `MDPIexploreR`. This article provides a brief introduction to the key functionalities of this package. Although all functions have been rigorously tested, occasional bugs or unexpected issues may arise. Please report any problems via [Github](https://github.com/pgomba/MDPI_explorer/issues). Similarly, and feel free to suggest enhancements or new features as well.

# Obtaining list of journals

`MDPIexploreR` functions rely on journal codes. These are usually the same as journal titles (e.g. Plants), but occasionally they are abbreviations (e.g., IJERPH). To find the code of the journal you plan to explore use the `MDPI_journals()` function. This function fetches data from the official MDPI journals page at [https://www.mdpi.com/about/journals](https://www.mdpi.com/about/journals) and generates a table containing the names of the journals along with their corresponding codes.

```{r}
MDPI_journals()|>head(10)
```


# Article level information

`MDPIexploreR` makes easy to obtain a list of all articles published in a journal. For example, to get a list of all articles published in the journal "MDPI Covid" we just need to do:

```{r cache=TRUE}
article_find("covid")|>head(5)
```

You can then use the `article_info()` function to obtain editorial information about these journals. For this example, let's extract information for a sample of ten articles from the journal *Covid*. Note that the more articles a journal has, the longer it will take to retrieve the information. A progress bar will display the current status. For large requests, I recommend having a stable internet connection and dividing the results of `article_find()` into smaller vectors. As a general rule, retrieving information for one article takes approximately 1.2 seconds—so plan accordingly!

```{r cache=TRUE}
all_covid_articles<-article_find("covid")
article_info(all_covid_articles,sample=10)
```
Visualize the output of `article_info()` using the `plot_articles()` function, which comes with three types of graphs:

```{r cache=TRUE}
all_covid_articles<-article_find("covid")
articles_data<-article_info(all_covid_articles,sample=100)

plot_articles(articles_data,journal = "Covid", type = "summary" )
plot_articles(articles_data,journal = "Covid", type = "type" )
plot_articles(articles_data,journal = "Covid", type = "issues" )
```
# Special issues and guest editors

Similar to the functions in the `article()` family, we will use a journal code to obtain information on special issues and gues editors. 
To compile a list of a journal special issues we use the `special_issue_find()` function. This function allows to obtain all special issus from a journal, limit the output to a year to year threshold and choose between open or closed articles. Lets find all closed special issues in the journal Plants, between the year 2021 and 2023: 

```{r cache=TRUE}
si<-special_issue_find("plants",type="closed", years = seq(2020,2023,1))
length(si)
si|>head(5)

```
To explore the role of guest editors in these special issues, we can use these URLs and the `guest_editor_info()` function. In this example we use this function on a sample of five articles:

```{r cache=TRUE}

guest_editor_info(sample(si,5))

```

The function outputs a table with several columns, including: the number of papers in the special issue (excluding editorial-type articles), the number of articles authored by a guest editor (`flags`), and the ratio of articles to flags (`prop_flag`), which indicates the fraction of articles authored by guest editors in the special issue. Additional columns include the deadline for the special issue, the date of the last article submission, and how much time, if any, the submission exceeded the deadline. The `rt_sum_vector2` column provides a count for each guest editor, representing the number of papers they authored in the special issue. Finally, the `aca_flag` column highlights the number of papers where the academic editor also served as a guest editor. 

# Self-cites

Full disclosure: the `rcrossref` package can work wonders when estimating self-citation rates. While the `selfcite_check()` function in this package does a good job as well, it relies on the information provided by MDPI in their references, which sometimes truncates author lists using 'et al.' As a result, I believe this function serves as a good starting point, but for more comprehensive analysis, additional tools like `rcrossref` may be needed. `selfcite_check` won't work if the paper is not directly available online (e.g., is only available in a pdf)

```{r cache=TRUE}
paper<-"https://www.mdpi.com/2313-7673/9/10/642"
selfcite_check(paper)

```

Happy exploring!
