Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/r-lib/rappdirs
Find OS-specific directories to store data, caches, and logs. A port of python's AppDirs
https://github.com/r-lib/rappdirs
appdir r
Last synced: 3 months ago
JSON representation
Find OS-specific directories to store data, caches, and logs. A port of python's AppDirs
- Host: GitHub
- URL: https://github.com/r-lib/rappdirs
- Owner: r-lib
- License: other
- Created: 2012-08-10T14:06:28.000Z (about 12 years ago)
- Default Branch: main
- Last Pushed: 2024-05-21T08:51:28.000Z (6 months ago)
- Last Synced: 2024-07-30T10:50:54.303Z (3 months ago)
- Topics: appdir, r
- Language: R
- Homepage: https://rappdirs.r-lib.org
- Size: 1.21 MB
- Stars: 82
- Watchers: 5
- Forks: 15
- Open Issues: 9
-
Metadata Files:
- Readme: README.Rmd
- License: LICENSE
- Code of conduct: .github/CODE_OF_CONDUCT.md
Awesome Lists containing this project
- jimsghstars - r-lib/rappdirs - Find OS-specific directories to store data, caches, and logs. A port of python's AppDirs (R)
README
---
output: github_document
---```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%"
)
```# rappdirs
[![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)`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/
If on Windows (at least English Win XP) that should be:
C:\Documents and Settings\\Application Data\Local Settings\\
or possibly:
C:\Documents and Settings\\Application Data\\
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/
or possibly:
~/.local/share/
## 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)
```