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

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

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

## The `produce_ef1_report` function requires 2 separate dataframes, one with row-level students and one with pre-aggregated retention counts.  
## *The dataframes must follow the format described below*



### Student data requirements

>
* One row per person
* One IPEDS Unitid per file
* Columns with values and types as described below in any order (additional columns are allowed)
* Double-starred column names (**) are only required in years when IPEDS collects that information. In off-years, you can omit the columns or enter any placeholder value. 

Column names can use any capitalization method you like. Do **NOT** include (**) in the column names.


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

tryCatch(specs_EF1 <- googlesheets4::read_sheet("https://docs.google.com/spreadsheets/d/1XVcGKtrAwsgKRYvqrbzO13-w8_u3IB2oYft-F5Psxx4/edit", sheet = 1),
         error = function(x) message("Google Sheet unavailable"),
         warning = function(y) message("There was a warning"))
usethis::use_data(specs_EF1, overwrite = TRUE)
```

```{r specstable_df, echo=FALSE, warning=FALSE, message=FALSE}
library(magrittr)
specs_EF1$ACCEPTABLE_VALUES <- stringr::str_replace_all(specs_EF1$ACCEPTABLE_VALUES, pattern = "\\n", replacement = "<br>")
specs_EF1_students <- specs_EF1[specs_EF1$DATA_FRAME == 'students', 2:4]
knitr::kable(specs_EF1_students,
             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')

```



### Retention data requirements 

>
* One row for full-time counts, one row for part-time counts
* One IPEDS Unitid per file
* Columns with values and types as described below in any order (additional columns are allowed)


```{r specstable_com, echo=FALSE, warning=FALSE, message=FALSE}
#figure out why striped isn't working when format = 'html'
specs_EF1_retention <- specs_EF1[specs_EF1$DATA_FRAME == 'retention', 2:4]
knitr::kable(specs_EF1_retention,
             format = 'html',
             escape = FALSE,
             col.names = c('Column Name', 'Column Type', 'Acceptable Value - Definition'),
             row.names = FALSE) %>%
    kableExtra::kable_styling(bootstrap_options = "striped") %>%
  kableExtra::column_spec(column = 2, italic = TRUE, width = '8em', )

```

### Student-faculty ratio

This information will be collected via pop-up box. Type the correct number for your institution's ratio when prompted.

