0

This question is related to chi square test for each row in data frame which was solved (but flagged incorrect stats. method thanks to @CathG). I have changed by approach - so the setup is rather different now. I have a data frame looking like this:

df <- data.frame(
item = c("red", "blue", "green", "orange", "yellow", "black", "purple"),
obs.1 = c(2,10,53,13,12,15,5),
obs.1expt = c(3,12,48,9,11,15,5),
obs.2 = c(3,12,45,2,7,17,5),
obs.2expt = c(3,14,40,3,9,20,5))

I now want to compare the numbers of observed and expected (expected = numbers expected to have been seen if each observer had spend the same time observing the process) between the two observers. Using a chi square I hope to answer if the two observers are equally efficient in detecting "items" of different color.

My question is how do I conduct a chisq() on each of the rows in the data frame and append the results (ch.sq and p) to the table. From what I understand I need I would need to input a matrix into chisq() - for the first row this would be (and than applied to all rows):

        count | expt.count
obs.1 |   2   |    3
obs.2 |   3   |    3

This would than feed into chisq().

Community
  • 1
  • 1
doncarlos
  • 401
  • 4
  • 16
  • how would you like to rearrange the data into a matrix? Like having three columns only ("item","variable name","value" (e.g. 2,10,53...)? – user3507584 Feb 13 '15 at 10:00
  • you can convert a dataframe to a matrix with `as.matrix(df)`, in a matrix, you can store objects of the same class (numeric, factor) only. how is your result supposed to look like? – rmuc8 Feb 13 '15 at 10:03
  • I have added some further details in terms of required output. – doncarlos Feb 13 '15 at 10:37

0 Answers0