Domanda

Is it possible to calculate chi squared in R when your data is in the form of a list of observations? What I mean is, it is simple to get chi squared if you know the cross. For instance, if you have a survey and you ask for gender and a true-false question, you only need four numbers to calculate the chi squared. What I have instead is two columns of data with each respondent's answers. Is it possible to get chi squared from this structure of the data, or do I have to convert it?

If I have to convert it for R, does anyone know of another language that will allow me to get the chi squared directly?

È stato utile?

Soluzione

If you use table before putting your data into chisq.test you should be fine

# Create some fake 'raw' data
dat <- data.frame(gender = sample(c("M","F"), 100,rep = T), ans = as.logical(rbinom(100,1,.3)))
head(dat)
# just use table to get the data into the form needed
chisq.test(table(dat))
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top