gen_number_1 {covalchemy} | R Documentation |
Generate a New Number for Stepwise Modification
Description
This function modifies a given contingency table by swapping values between two cells
in a stepwise manner, where the change is fixed at a delta
value of 1. The function
randomly selects two cells from the table and adjusts their values by subtracting and
adding the delta
value.
Usage
gen_number_1(x)
Arguments
x |
A contingency table (numeric matrix or table). |
Details
This function performs the following steps:
Randomly selects two rows and two columns from the table.
Ensures that the selected cells have non-zero values.
Adjusts the values of the selected cells by subtracting 1 from two cells and adding 1 to the other two.
Returns the modified table with stepwise adjustments.
Value
A modified contingency table with stepwise adjustments.
Examples
# Example usage with a contingency table:
pair_table <- table(c(1, 2, 2, 3), c(1, 1, 2, 2))
gen_number_1(pair_table)
[Package covalchemy version 1.0.0 Index]