I am new to R and am looking for some help on automatically producing a series of contingencyTableBF objects for tables created from my data. I want to use such a contingency table as it generates Bayes Factor values for each table. I have searched on the internet without success and on stackoverflow, where I found the below guidance, but I don't know how to convert it to my purpose:
R: Count or contingency tables produced using a loop
In terms of the contingencyTableBF, I wish to use the following parameters related to sampleType and fixedMargin, with the C_BA object being the name of a table I created:
contingencyTableBF(C_BA, sampleType = "indepMulti", fixedMargin = "cols")
I have used the code below to create a table, and ideally would also like to automate this process for all tables. The purpose of each table is to demonstrate the totals between the Dependent Variable and any given Predictor Variable. With the filter function, I have used == and != instructions to generate the four values in the matrix. I wish to generate separate tables to indicate the totals for the Dependent Variable and each Predictor Variable in my data
TRG <- filter(dataset, DependentVariable == 1 & PredictorVariable == 1)
C_BA <- matrix(c(554, 1631, 336, 2078), ncol = 2, byrow = T)
colnames(C_BA) <- c("DependentVariable", "NotDependentVariable")
rownames(C_BA) <- c("PredictorVariable", "NotPredictorVariable")
C_BA <- as.table(C_BA)
C_BA
Any help would be great, thanks very much