get_ratio.RdCalculates 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.
get_ratio(
data,
treatment,
control,
ratio_colname = "ratio",
missing_colname = "missing",
bind = TRUE
)data.frame.
variable. Name of numeric column in the data.frame.
character. Name for the output ratio column
character. Name for the output missing column
logical. Should the resulting ratios be added to data
as a column? Default is TRUE.
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.
my_data <- data.frame(
treatment = c(30, NA, 12, NA),
control = c(20, 12, NA, NA)
)
my_data2 <- get_ratio(my_data, treatment, control)