---
title: "Set up your data for IPEDS GR processing"
output: rmarkdown::html_vignette
vignette: >
  %\VignetteIndexEntry{Set up your data for IPEDS GR processing}
  %\VignetteEngine{knitr::rmarkdown}
  %\VignetteEncoding{UTF-8}
---

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

```{r setup, eval=FALSE, echo=FALSE}
library(IPEDSuploadables)
```

```{r specsimport, eval = FALSE, echo = FALSE}
#this chunk is only used during interactive session by the package maintainers, if the requirements have been updated

tryCatch(specs_GR <-  googlesheets4::read_sheet('1HR0W3N5AgsdwppvTr7CZ4Q2IQtfnTfXMJsSP8l-JtLQ'),
        error = function(x) message("Google Sheet unavailable"),
        warning = function(y) message("There was a warning"))

usethis::use_data(specs_GR, overwrite = TRUE) 
```

## To use the `produce_gr_report` function, your student graduation data must be in the format described below

>
* One row per person
* One IPEDS Unitid per file
* Columns with values and types as described below (additional columns are allowed)

This population should meet IPEDS rules for inclusion on this report (first-time full-time degree/certificate seekers from the appropriate cohort year).


```{r create_data_file_in_package, eval=FALSE, echo=FALSE}
#export spreadsheet with specs from google drive
#read in with readr
specs_GR <- googlesheets4::read_sheet("https://docs.google.com/spreadsheets/d/1HR0W3N5AgsdwppvTr7CZ4Q2IQtfnTfXMJsSP8l-JtLQ/edit#gid=0", sheet = 1)
usethis::use_data(specs_GR, overwrite = TRUE)
```


```{r specstable, echo=FALSE, warning=FALSE, message=FALSE}
#figure out why striped isn't working when format = 'html'
load("../data/specs_GR.rda")
library(magrittr)
specs_GR$ACCEPTABLE_VALUES <- stringr::str_replace_all(specs_GR$ACCEPTABLE_VALUES, pattern = "\\n", replacement = "<br>")
knitr::kable(specs_GR, 
             format = 'html',
             escape = FALSE,
             col.names = c('Column Name', 'Column Type', 'Acceptable Value - Definition')) %>%
    kableExtra::kable_styling(bootstrap_options = "striped") %>%
    kableExtra::column_spec(2, italic = TRUE, width = '8em')
```

