---
title: "Load ILSA files"
output: rmarkdown::html_vignette
vignette: >
  %\VignetteIndexEntry{Load}
  %\VignetteEngine{knitr::rmarkdown}
  %\VignetteEncoding{UTF-8}
---

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

```{r, echo=FALSE}
library(ILSAmerge)
```

## Check what can be loaded

Using `ILSAfile.info()` we can identify different populations within an ILSA.

Moreover, we can also use this information for loading an specific population
into the memory. Using the 'REDS' 2021 example data provided by this package:
```{r}

ILSAfile.info(inputdir = system.file("extdata/reds", package = "ILSAmerge"))

```

## Load all information

We can decide to load a population, like `BCGV1`, using `justload()`:
```{r}
loaded <- justload(inputdir = system.file("extdata/reds", package = "ILSAmerge"),
         population = "BCGV1")
```

This will result in a list of elements loaded by `haven`, in our example, a list
of 11 elements:
```{r}
class(loaded)

length(loaded)

loaded[[1]]
```

## Load only column information

For some purposes, we might need to load only the column information, most 
probably to check if the attributes are correct. We can do this by setting
`justattributes = TRUE`:
```{r}
loaded <- justload(inputdir = system.file("extdata/reds", package = "ILSAmerge"),
         population = "BCGV1", justattributes = TRUE)
```

This will load all 11 datasets with 0 rows each:
```{r}
length(loaded)

loaded[[1]]
```






