Hi, I have a table in R with data I needed and need to create a contingency table out of it. The table I have so far looks like this: Binger r DietType No Yes Dangerous 15 12 Healthy 52 9 None 134 24 Unhealthy 72 23 These are the error messages that I keep getting whenever I try to get a contingency table. I'm not sure why it won't work for me, any help would be appreciated!> nametable<-table(excat,recat)Error in table(excat, recat) : object 'excat' not found [[alternative HTML version deleted]]
Hi Laura and R users, I would like to know whether we can do siginificance test between Column Yes and Column No. Any one tried? I have seen it in Tabulaiton software packages from our vendors and in SPSS Custom Table. Thanks, On Wed, Mar 2, 2011 at 7:43 PM, Laura Clasemann <violagirl470@msn.com>wrote:> > Hi, > > I have a table in R with data I needed and need to create a contingency > table out of it. The table I have so far looks like this: > > > Binger > r > DietType No Yes > Dangerous 15 12 > Healthy 52 9 > None 134 24 > Unhealthy 72 23 > > These are the error messages that I keep getting whenever I try to get a > contingency table. I'm not sure why it won't work for me, any help would be > appreciated! > > nametable<-table(excat,recat) > Error in table(excat, recat) : object 'excat' not found > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html<http://www.r-project.org/posting-guide.html> > and provide commented, minimal, self-contained, reproducible code. >[[alternative HTML version deleted]]
Hi Laura, On Wed, Mar 2, 2011 at 9:13 AM, Laura Clasemann <violagirl470 at msn.com> wrote:> > Hi, > > I have a table in R with data I needed and need to create a contingency table out of it. The table I have so far looks like this: > > > ? ? ? ? ? ? ? ? ? Binger > r > DietType ? ? No Yes > ?Dangerous ?15 ?12 > ?Healthy ? ?52 ? 9 > ?None ? ? ?134 ?24 > ?Unhealthy ?72 ?23 > > These are the error messages that I keep getting whenever I try to get a contingency table. I'm not sure why it won't work for me, any help would be appreciated! >> nametable<-table(excat,recat) > Error in table(excat, recat) : object 'excat' not foundThat error seems pretty clear. The table function can't find the excat data. Is it in a data.frame or a list? Perhaps ?with will point you in the rigth direction. Best, Ista> > ? ? ? ?[[alternative HTML version deleted]] > > ______________________________________________ > R-help at r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. >-- Ista Zahn Graduate student University of Rochester Department of Clinical and Social Psychology http://yourpsyche.org
On 03/03/2011 01:13 AM, Laura Clasemann wrote:> > Hi, > > I have a table in R with data I needed and need to create a contingency table out of it. The table I have so far looks like this: > > > Binger > r > DietType No Yes > Dangerous 15 12 > Healthy 52 9 > None 134 24 > Unhealthy 72 23 > > These are the error messages that I keep getting whenever I try to get a contingency table. I'm not sure why it won't work for me, any help would be appreciated! >> nametable<-table(excat,recat) > Error in table(excat, recat) : object 'excat' not found >Hi Laura, The above looks like a contingency table, but I suspect that it is in a format that is not recognized as such by R. If I read in the above, less the top two lines ("Binger" and "r"), I get a data frame. lc.df<-read.table("lc.dat",header=TRUE) lc.df DietType No Yes 1 Dangerous 15 12 2 Healthy 52 9 3 None 134 24 4 Unhealthy 72 23 If I then try to run a chi-square test on the numeric columns of the data frame, chisq.test(lc.df[,2:3]) Pearson's Chi-squared test data: lc.df[, 2:3] X-squared = 14.5011, df = 3, p-value = 0.002297 I get the expected result. If the table in your message is something like a table in a word processing document or a text file, R doesn't know what it is. If it is indeed an R object (which I doubt) it probably isn't named "excat" (or "recat" for that matter). That may be what is causing the error message. A final point is that you probably want your table arranged in order of the presumed healthiness of the diet, i.e. Healthy None Unhealthy Dangerous because I think you are trying to discover whether bingers are more likely to report less healthy diets. Jim
Did you get a reply on this? We really need to see your code and some sample data. Have a look at ?dput tko supply some data. At the moment it looks like R is not recognizing the dara set. If ls( libts the dataset, are you using mydara$excat --- On Wed, 3/2/11, Laura Clasemann <violagirl470 at msn.com> wrote:> From: Laura Clasemann <violagirl470 at msn.com> > Subject: [R] Contingency table in R > To: r-help at r-project.org > Received: Wednesday, March 2, 2011, 9:13 AM > > Hi, > > I have a table in R with data I needed and need to create a > contingency table out of it. The table I have so far looks > like this: > > > ? ? ? ? ? ? ? ? > ???Binger > r > DietType? ???No Yes > ? Dangerous? 15? 12 > ? Healthy? ? 52???9 > ? None? ? ? 134? 24 > ? Unhealthy? 72? 23 > > These are the error messages that I keep getting whenever I > try to get a contingency table. I'm not sure why it won't > work for me, any help would be appreciated! > > nametable<-table(excat,recat) > Error in table(excat, recat) : object 'excat' not found > ??? > ???????? > ?????? ??? > ? > ??? [[alternative HTML version deleted]] > > ______________________________________________ > R-help at r-project.org > mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, > reproducible code. >