Skip to content
/ dirr Public

R package to create default data project directories and provide useful file manipulation functions

Notifications You must be signed in to change notification settings

bgulbis/dirr

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

38 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

dirr

Purpose

The dirr package can be used to set up a data project with default folders. Additionally, utility functions to compress data files and batch load/save Rds are provided.

Installation

The dirr package can be installed from GitHub using the devtools package and the following commands:

# install.packages("devtools")
library(devtools)

install_github("bgulbis\dirr")

How to Use

Create project directories

  1. Create a new project folder, in RStudio or other
  2. Load the dirr package
  3. Run the make_dirs function
libryar(dirr)

make_dirs()

Output

The following folders are created by make_dirs:

  • data/external - any external data, such as data which was manually collected
  • data/final - final version of the data used for analysis
  • data/raw - original, raw data sets
  • data/tidy - tidy version of original data sets
  • doc - manuscript and related documents
  • explore - exploratory notebooks and figures
  • figs - final figures for posters or manuscript
  • ref - reference articles for the project
  • report - notebook containing data analysis
  • src - R script files used to tidy, transform, and aggregate data into the final data set

Compress data files

  1. Load the dirr package
  2. Run the gzip_files function to compress all data files in the data/raw directory, or other specified directory
library(dirr)

gzip_files()
  • Use the pattern argument to specify only certain files for zipping
  • Use ungzip_files to uncompress all data files

Batch read and save Rds files

  1. Load the dirr package
  2. Run the save_rds function to save all R objects in the Global Environment whose names match the regular expression passed to the pattern argument. The directory where the files are saved is specified by the data.dir argument
  3. Use get_rds to load all files in the specified directory.
library(dirr)

# save all objects that begin with "tidy"
save_rds(data.dir = "data/tidy", pattern = "^tidy")

# read all Rds files
get_rds(data.dir = "data/tidy")
  • Currently, the file.ext argument should be left as default.

About

R package to create default data project directories and provide useful file manipulation functions

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages