| Title: | Enhance the Ease of R Experience as an Emerging Researcher | 
| Version: | 0.1.0 | 
| Description: | A toolkit of functions to help: i) effortlessly transform collected data into a publication ready format, ii) generate insightful visualizations from clinical data, iii) report summary statistics in a publication-ready format, iv) efficiently export, save and reload R objects within the framework of R projects. | 
| License: | MIT + file LICENSE | 
| Encoding: | UTF-8 | 
| RoxygenNote: | 7.2.3 | 
| Imports: | ggplot2, here, RColorBrewer, rstudioapi, scales, stats | 
| Depends: | R (≥ 2.10) | 
| Suggests: | knitr, rmarkdown | 
| VignetteBuilder: | knitr | 
| LazyData: | true | 
| URL: | https://dahhamalsoud.github.io/phdcocktail/, https://github.com/DahhamAlsoud/phdcocktail | 
| BugReports: | https://github.com/DahhamAlsoud/phdcocktail/issues | 
| NeedsCompilation: | no | 
| Packaged: | 2023-12-02 11:43:00 UTC; Dahham | 
| Author: | Dahham Alsoud  | 
| Maintainer: | Dahham Alsoud <dahhamalsoud@gmail.com> | 
| Repository: | CRAN | 
| Date/Publication: | 2023-12-04 17:00:03 UTC | 
Get a safe name to export a file without overwriting
Description
Get a safe name to export a file without overwriting
Usage
get_safe_file_name(
  data,
  name = NULL,
  format = "xlsx",
  overwrite = FALSE,
  time_in_name = FALSE
)
Arguments
data | 
 The object to be exported.  | 
name | 
 A desired name for the exported file. If no name is provided, the file will inherit the object's name.  | 
format | 
 The format of the exported file. Default is 'xlsx'.  | 
overwrite | 
 A logical to indicate whether preexisting files with identical names should be overwritten. Default is 'FALSE'.  | 
time_in_name | 
 A logical to indicate whether a timestamp should be included in the file's name.  | 
Value
A safe name for exporting the file, as a "character string", and also indicated in a message.
Examples
if (FALSE) {
  library(phdcocktail)
  get_safe_file_name(mtcars)
}
Get a safe name to save current workspace without overwriting
Description
Get a safe name to save current workspace without overwriting
Usage
get_safe_workspace_name(name = "analysis", time_in_name = TRUE)
Arguments
name | 
 A desired name for the saved workspace. If no name is provided, the name will be 'analysis'.  | 
time_in_name | 
 A logical to indicate whether a timestamp should be included in the workspace's name.  | 
Value
A safe name for exporting the workspace, as a "character string", and also indicated in a message.
Examples
if (FALSE) {
  library(phdcocktail)
  get_safe_workspace_name()
}
Inflammatory Bowel Disease (IBD) datasets
Description
'ibd_data1' and 'ibd_data2' are two small datasets containing data collected from IBD patients, more specifically patients with Crohn's disease. 'ibd_data2' is a modified version of 'ibd_data1' by introducing missing and incorrect entries 'L11' into the column 'disease_location'.
Usage
ibd_data1
ibd_data2
Format
Two data frames with each 30 rows and six columns:
- patientid
 Patient ID
- gender
 Gender
- disease_location
 Disease location
- disease_behaviour
 Disease behaviour
- crp_mg_l
 C-reactive protein (mg/L)
- calprotectin_ug_g
 Faecal calprotectin (ug/g)
Source
Randomly generated data
Data dictionary for Inflammatory Bowel Disease (IBD) data
Description
A small, non-exhaustive list of variables that are commonly collected in IBD research. For each variable and its levels, if applicable, publications-ready labels are provided
Usage
ibd_data_dict
Format
A data frame with 53 rows and four columns:
- variable
 Variable name in the 'short', i.e. 'excel', form
- variable_label
 Variable name in the publication form
- value
 Value name in the 'short', i.e. 'excel', form
- value_label
 Value name in the publication form
Inflammatory Bowel Disease (IBD) outcomes
Description
A table containing proportions and percentages of IBD patients achieving clinical outcomes.
Usage
ibd_outcomes
Format
A data frame with eight rows and seven columns:
- outcome
 Outcome type
- timepoint
 Assessment timepoint
- achieved
 Number of patients who achieved the outcome
- total
 Total number of patients
- proportion
 Proportion of patients who achieved the outcome
- percentage
 Percentage of patients who achieved the outcome
- percentage_labelled
 Percentage of patients who achieved the outcome, suffixed with '%'
Identify the most recent saved R workspace
Description
Identify the most recent saved R workspace
Usage
identify_recent_workspace(folder = "output")
Arguments
folder | 
 The folder in which the workspace need to be identified.  | 
Value
The most recent saved workspace, as a "character string", and also indicated in a message.
Examples
library(phdcocktail)
if (FALSE) {
  identify_recent_workspace()
}
Plot % of outcomes as bars
Description
Plot % of outcomes as bars
Usage
plot_bars(
  data,
  outcome,
  proportion,
  percentage_labelled,
  achieved,
  total,
  x_axis_title = NULL,
  y_axis_title = "% Patients",
  legend_title = "Outcome",
  bar_fill = "Greys",
  grouping = NULL
)
Arguments
data | 
 A data frame containing outcomes data.  | 
outcome | 
 Variable containing outcomes to be plotted.  | 
proportion | 
 Variable containing proportion of patients who achieved the outcome.  | 
percentage_labelled | 
 Variable containing percentage of patients who achieved the outcome, suffixed with '%' label.  | 
achieved | 
 Variable containing number of patients who achieved the outcome.  | 
total | 
 Variable containing total number of patients.  | 
x_axis_title | 
 Title of the x-axis.  | 
y_axis_title | 
 Title of the y-axis.  | 
legend_title | 
 Title of the legend.  | 
bar_fill | 
 Fill color of the bars.  | 
grouping | 
 Faceting variable.  | 
Value
A bar plot of outcome percentages.
Examples
if (FALSE) {
library(phdcocktail)
data(ibd_outcomes, package = "phdcocktail")
plot_bars(ibd_outcomes)
  }
A custom print method for the 'quantiles_report' class
Description
A custom print method for the 'quantiles_report' class
Usage
## S3 method for class 'quantiles_report'
print(x, ...)
Arguments
x | 
 A data frame of the class 'quantiles_report'.  | 
... | 
 Other argument that can be passed to 'print'.  | 
Value
The function displays the content of the column 'report' in separate lines.
Examples
if (FALSE) {
library(phdcocktail)
summary_data <- report_quantiles(mtcars, summary_vrs = "mpg")
print(summary_data)
  }
Recode variables and their values based on a data dictionary
Description
Recode variables and their values based on a data dictionary
Usage
recode_vrs(data, data_dictionary, vrs = NULL, factor = FALSE)
Arguments
data | 
 A data frame with raw data.  | 
data_dictionary | 
 A data dictionary containing labels for variables and their values.  | 
vrs | 
 A character vector specifying variables of which the values need to be recoded.  | 
factor | 
 A logical to indicate whether recoded variables need to be converted into ordered factors.  | 
Value
The input data frame with recoded and labelled variables.
Examples
if (FALSE) {
  library(phdcocktail)
  data(ibd_data1, package = "phdcocktail")
  ibd_data_recoded <- recode_vrs(
    data = ibd_data1, data_dictionary = ibd_data_dict,
    vrs = c("disease_location", "disease_behaviour", "gender"), factor = TRUE
  )
}
Report median-quantiles summaries
Description
Report median-quantiles summaries
Usage
report_quantiles(data, summary_vrs, grouping_vrs = NULL)
Arguments
data | 
 A data frame including numeric variables to be summarized.  | 
summary_vrs | 
 A character vector specifying the numeric variables to be summarized.  | 
grouping_vrs | 
 A character vector specifying the grouping variables, if any.  | 
Value
A dataframe of the class 'quantiles_report', containing a 'report' column, which report the 'median (quartile 1-quartile 3)' combinations for each specified numeric variable, at each grouping key.
Examples
if (FALSE) {
library(phdcocktail)
summary_data <- report_quantiles(mtcars, summary_vrs = "mpg")
print(summary_data)
  }
Restart R session
Description
Restart R session
Usage
start_fresh()
Value
A clean R session
Examples
if (FALSE) {
library(phdcocktail)
start_fresh()
  }