---
title: "Data sources for vitae"
output: rmarkdown::html_vignette
vignette: >
  %\VignetteIndexEntry{Using vitae with other packages}
  %\VignetteEngine{knitr::rmarkdown}
  %\VignetteEncoding{UTF-8}
---

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

Using data to dynamically build your Résumé or CV makes many powerful integrations possible. By using data to populate entries in the document, it becomes easy to manipulate and select relevant experiences for a particular application. There are many sources of data which can be used to populate a CV with vitae, some commonly sources are summarised in this vignette.

The main purpose of sourcing your CV entries from common data sources is to extend the "do not repeat yourself" programming philosophy to maintaining a CV. If you maintain publications on [ORCID](https://orcid.org/) you shouldn't need to repeat these entries in your CV. If a list of talks you've made can be found on your website, avoid repeating the list in multiple locations to ensure that they both contain the same content.

This vignette is far from comprehensive, and there are no doubt many other interesting ways to populate your CV with data. If you're using a data source that you think others should know about, consider making a [pull request](https://github.com/mitchelloharawild/vitae/pulls) that adds your method to this vignette.

## Spreadsheets and data sets

The simplest source of entries for vitae are maintained dataset(s) of past experiences and achievements. Just like any dataset, these entries can be loaded into the document as a `data.frame` or `tibble` using functions from base R or the [`readr` package](https://readr.tidyverse.org/).

```r
readr::read_csv("employment.csv") %>% 
  detailed_entries(???)
```

It is also possible to load in data from excel using the [`readxl` package](https://readxl.tidyverse.org/) or from Google Sheets using the [`googlesheets` package](https://github.com/jennybc/googlesheets).

```r
readxl::read_excel("awards.xlsx") %>% 
  brief_entries(???)
```

## Google scholar

Google Scholar does not require authentication to extract publications. Using the [`scholar` package](https://github.com/jkeirstead/scholar), it is easy to extract a user's publications from their Google Scholar ID. To obtain publications for an individual, you would first find your ID which is accessible from your profile URL. For example, Rob Hyndman's ID would be `"vamErfkAAAAJ"` (https://scholar.google.com/citations?user=vamErfkAAAAJ&hl=en).

```r
scholar::get_publications("vamErfkAAAAJ") %>% 
  detailed_entries(
    what = title,
    when = year,
    with = author,
    where = journal,
    why = cites
  )
```

## Bibliography files

The vitae package directly supports loading `*.bib` files using the `bibliography_entries()` function, which formats the entries in a bibliography style.

```r
bibliography_entries("publications.bib")
```

It is also possible to display the contents of your bibliography using template specific entries formats.

```r
bibliography_entries("publications.bib") %>% 
  detailed_entries(???)
```

## R packages

A list of R packages that you have helped develop can be obtained using the [`pkgsearch` package](https://github.com/r-hub/pkgsearch).

```r
pkgsearch::ps("O'Hara-Wild",size = 100) %>%
  filter(map_lgl(package_data, ~ grepl("Mitchell O'Hara-Wild", .x$Author, fixed = TRUE))) %>% 
  as_tibble() %>% 
  brief_entries(
    what = title, 
    when = lubridate::year(date), 
    with = description
  )
```

