---
execute: 
  eval: false
---


## Set the data directory {#set-data-folder}

Choose where `{spanishoddata}` should download (and convert) the data by setting the data directory following command:

```{r}
spod_set_data_dir(data_dir = "~/spanish_od_data")
```

The function above will also ensure that the directory is created and that you have sufficient permissions to write to it.

<details><summary>Setting data directory for advanced users</summary>

You can also set the data directory with an environment variable:

```{r}
Sys.setenv(SPANISH_OD_DATA_DIR = "~/spanish_od_data")
```

The package will create this directory if it does not exist on the first run of any function that downloads the data.

To permanently set the directory for all projects, you can specify the data directory globally by setting the `SPANISH_OD_DATA_DIR` environment variable, e.g. with the following command:

```{r}
#| eval: false
usethis::edit_r_environ()
# Then set the data directory globally, by typing this line in the file:
```

```
SPANISH_OD_DATA_DIR = "~/spanish_od_data"
```

You can also set the data directory locally, just for the current project. Set the 'envar' in the working directory by editing `.Renviron` file in the root of the project:

```{r}
#| eval: false
file.edit(".Renviron")
```


</details>
