get_ratio: Get ratio of two numbers

View source: R/get_ratio.R

get_ratioR Documentation

Get ratio of two numbers

Description

Calculates the ratio of two numeric columns in a data.frame, and indicates if there are missing values. Calculation is: trt - ctr. Typically used to calculate the ratio of two log2 transformed SILAC/label-free intensity columns.

Usage

get_ratio(
  data,
  treatment,
  control,
  ratio_colname = "ratio",
  missing_colname = "missing",
  bind = TRUE
)

Arguments

data

data.frame.

treatment, control

variable. Name of numeric column in the data.frame.

ratio_colname

character. Name for the output ratio column

missing_colname

character. Name for the output missing column

bind

logical. Should the resulting ratios be added to data as a column? Default is TRUE.

Value

Returns data with 2 new columns: ratio (a numeric column) and missing (a character column indicating if there was missing values in treament and/or control). Returns a ⁠named list⁠ if bind = FALSE.

Examples

my_data <- data.frame(
  treatment = c(30, NA, 12, NA),
  control = c(20, 12, NA, NA)
)

my_data2 <- get_ratio(my_data, treatment, control)

CambridgeCentreForProteomics/camprotR documentation built on July 7, 2024, 2:13 a.m.