I am trying to calculate chisq.test and print our residuals and p.value for each run
p_values <- numeric(nrow(df))
for (i in 1:nrow(df)) {
table <- c(df$eu[i], df$hetero[i])
result <- chisq.test(table)
residuals[i] <- result$residuals
p_values[i] <- result$p.value
result$p.value
}
df$residuals <- residuals
df@p_value <- p_values
I receive this error:
Error in (function (cl, name, valueClass) :
‘p_value’ is not a slot in class “data.frame”
Column 1 | Column 2 |
---|---|
eu | hetero |
0.00010600 | 0.00002300 |
0.00009900 | 0.00001000 |
0.00010600 | 0.00000700 |
0.00009100 | 0.00001500 |
0.00011100 | 0.00000900 |
0.00008800 | 0.00003000 |
0.00010500 | 0.00004100 |
0.00009900 | 0.00000500 |
0.00010400 | 0.00000700 |