Skip to content

statsExtra parameter: perfoming Fisher's exact test on each variable #1

@dBenedek

Description

@dBenedek

Hello,

I am trying to pass Fisher's exact test calculation on each row variable compared to the column grouping variable:

summaryTable_hpv_neg <- computeSummaryStatisticsTable(
  data = clindats_merged_hpvneg,
  var = colnames(clindats_merged_hpvneg)[2:4],
  colVar = c("Cohort", "MPS"),
  #colVarTotal="Cohort",
  #colTotalInclude=T,
  stats = list(expression(paste0(statN, " (", round(statPercN, 1), "%)"))),
  statsExtra = list(`P value` = function(data, x) fisher.test(table(data$x, data$MPS))$p.value),
  statsVarBy="Cohort", 
  dataTotal = clindats_merged,
  subjectVar="patient_ID"
)

So for each row variable, I would like to run a Fisher's test with the MPS column variable to see the association between them.

But I get the following error message:

Error in table(data$x, data$MPS) :
all arguments must have the same length

Could you help me with how should I properly formulate a statistical test in the statsExtra parameter?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions