Package 'org'

Title: Organising Projects
Description: A system to help you organize projects. Most analyses have three (or more) main sections: code, results, and data, each with different requirements (version control/sharing/encryption). You provide folder locations and 'org' helps you take care of the details.
Authors: Richard Aubrey White [aut, cre] , CSIDS [cph]
Maintainer: Richard Aubrey White <[email protected]>
License: MIT + file LICENSE
Version: 2024.6.5
Built: 2024-11-03 05:36:26 UTC
Source: https://github.com/csids/org

Help Index


Create example project that uses quarto with results generated outside the .qmd file

Description

Create example project that uses quarto with results generated outside the .qmd file

Usage

create_project_quarto_external_results(home, results)

Arguments

home

Location of the 'home' directory.

results

Location of the 'results' directory.


Create example project that uses quarto with results generated from within the .qmd file

Description

Create example project that uses quarto with results generated from within the .qmd file

Usage

create_project_quarto_internal_results(home, results)

Arguments

home

Location of the 'home' directory.

results

Location of the 'results' directory.


Initializes project

Description

org::initialize_project takes in 2+ arguments. It then saves folder locations in the return value (a new environment) and in org::project, which you will use in all of your subsequent code. An additional folder will be created on the user's file system (org::project$results_today) which corresponds to results/YYYY-MM-DD. The sourced folders are saved into org::project$env.

Usage

initialize_project(
  env = new.env(),
  home = NULL,
  results = NULL,
  folders_to_be_sourced = "R",
  source_folders_absolute = FALSE,
  encode_from = "UTF-8",
  encode_to = "latin1",
  ...
)

Arguments

env

The environment that the code will be sourced into (use .GlobalEnv to source code into the global environment)

home

The folder containing 'Run.R' and 'R/'

results

A folder inside results with today's date will be created and it will be accessible via org::project$results_today (this is where you will store all of your results)

folders_to_be_sourced

The names of folders that live inside home and all .r and .R files inside it will be sourced into the global environment.

source_folders_absolute

If TRUE then folders_to_be_sourced is an absolute folder reference. If FALSE then folders_to_be_sourced is relative and inside home.

encode_from

Folders current encoding (only used on Windows)

encode_to

Folders final encoding (only used on Windows)

...

Other folders that you would like to reference

Details

For more details see the help vignette: vignette("intro", package = "org")

Value

Returns an environment that contains:

  • Folder locations

  • An environment called env into which the code has been sourced into. There is also a side effect where org::project mirrors these values.

Examples

org::initialize_project(
  home = paste0(tempdir(), "/git/analyses/2019/analysis3/"),
  results = paste0(tempdir(), "/dropbox/analyses_results/2019/analysis3/"),
  raw = paste0(tempdir(), "/data/analyses/2019/analysis3/")
)
org::project$results_today
org::project$raw

List files and directories Equivalent to the unix ls command.

Description

List files and directories Equivalent to the unix ls command.

Usage

ls_files(path = ".", regexp = NULL)

Arguments

path

A character vector of one or more paths.

regexp

A regular expression that is passed to list.files.

Value

filepaths and directory paths as a character vector


Move directory

Description

Move directory

Usage

move_directory(from, to, overwrite_to = FALSE)

Arguments

from

Filepath or directory path.

to

Filepath or directory path.

overwrite_to

Boolean.


Is a package installed?

Description

Is a package installed?

Usage

package_installed(pkg)

Arguments

pkg

Package name.

Value

Boolean. True if package is installed, false if not.

Examples

org::package_installed("data.table")

Construct path to a file or directory

Description

Construct path to a file or directory

Usage

path(...)

Arguments

...

Character vectors that will be concatenated with "/" as a separator.


Folders to be used/referenced (environment)

Description

Folders to be used/referenced (environment)

Usage

project

Format

An object of class environment of length 0.


Set results folder after initialization

Description

Set results folder after initialization

Usage

set_results(results, proj = org::project)

Arguments

results

A folder inside results with today's date will be created and it will be accessible via org::project$results_today (this is where you will store all of your results)

proj

The project environment (default is org::project)

Value

Nothing. There is a side effect where the environments proj and org::project have the values $results and $results_today altered.


Write text to a file

Description

Write text to a file

Usage

write_text(
  txt,
  file = "",
  header = "**THIS FILE IS CONSTANTLY OVERWRITTEN -- DO NOT MANUALLY EDIT**\r\n\r\n"
)

Arguments

txt

Text to be written

file

File, passed through to base::cat

header

Optional header that is inserted at the top of the text file

Value

No return value.