-
Notifications
You must be signed in to change notification settings - Fork 16
/
README.Rmd
88 lines (61 loc) · 2.43 KB
/
README.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
---
output: github_document
---
<!-- README.md is generated from README.Rmd. Please edit that file -->
```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%"
)
```
# rappdirs
<!-- badges: start -->
[![R-CMD-check](https://github.com/r-lib/rappdirs/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/r-lib/rappdirs/actions/workflows/R-CMD-check.yaml)
[![Codecov test coverage](https://codecov.io/gh/r-lib/rappdirs/branch/main/graph/badge.svg)](https://app.codecov.io/gh/r-lib/rappdirs?branch=main)
<!-- badges: end -->
`rappdirs` is a port of [appdirs](https://github.com/ActiveState/appdirs) to R.
It lets you find the appropriate directory to save caches, logs, and data, on Linux, Mac, and Windows.
It allows you to store files that need to shared across R sessions in a way that aligns with the [CRAN policies](https://cran.r-project.org/web/packages/policies.html).
## Motivation
What directory should your app use for storing user data?
If running on Mac OS X, you should use:
~/Library/Application Support/<AppName>
If on Windows (at least English Win XP) that should be:
C:\Documents and Settings\<User>\Application Data\Local Settings\<AppAuthor>\<AppName>
or possibly:
C:\Documents and Settings\<User>\Application Data\<AppAuthor>\<AppName>
for [roaming profiles](https://learn.microsoft.com/en-us/previous-versions/windows/it-pro/windows-vista/cc766489(v=ws.10)) but that is another story.
On Linux (and other Unices) the dir, according to the [XDG spec](https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html) (and subject to some interpretation), is either:
~/.config/<AppName>
or possibly:
~/.local/share/<AppName>
## Installation
Stable version:
```r
install.packages("rappdirs")
```
Development version:
```r
pak::pak("r-lib/rappdirs")
```
## Usage
This kind of thing is what rappdirs is for.
rappdirs will help you choose an appropriate:
- user data dir (`user_data_dir()`)
- user config dir (`user_config_dir()`)
- user cache dir (`user_cache_dir()`)
- site data dir (`site_data_dir()`)
- user log dir (`user_log_dir()`)
For example, on Mac:
```{r}
library(rappdirs)
appname <- "SuperApp"
appauthor <- "Acme"
user_config_dir(appname, appauthor)
user_data_dir(appname, appauthor)
site_data_dir(appname, appauthor)
user_cache_dir(appname, appauthor)
user_log_dir(appname, appauthor)
```