I have the following input that I named structure
:
structure <- structure(list(`1988` = c(NA, 17L, 4L, 249L, NA, NA), `1998` = c(1L,
57L, 1L, 123L, 114L, NA), `2008` = c(7L, 65L, 3L, 112L, 16L,
13L), `2018` = c(1L, 90L, 10L, 19L, 15L, NA)), class = "data.frame", row.names = c(NA,
-6L))
Here's the code I'm using:
p.value.structure <- structure %>%
chisq.test() %>%
glance() %>%
pull(p.value)
I want to pull out the p-value, but I keep getting the error:
Error in chisq.test(.) :
all entries of 'x' must be nonnegative and finite
Is there any way I can put the p-value into the p.value.structure
object?
fcas80
2
I suspect chisq.test() does not want NAs.
startz
3
I think the problem is the NAs in the data.
Is there a way to just output, "There are NAs in the data."?
startz
5
withoutNA <- na.omit(structure)
chisq.test(withoutNA)
But note that this leaves you with very few observations.
system
Closed
6
This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.
If you have a query related to it or one of the replies, start a new topic and refer back with a link.