Oh,
That's clearer now.

You should use two equal vectors when using table.
For example:
a <- c("a","b","a","b","a","b","a","b")
b <- c(1,1,1,1,2,2,2,2)
table(a,b)

also have a look at
?as.table
and
?matrix

Does that help ?

Tal

----------------Contact
Details:-------------------------------------------------------
Contact me: tal.gal...@gmail.com |  972-52-7275845
Read me: www.talgalili.com (Hebrew) | www.biostatistics.co.il (Hebrew) |
www.r-statistics.com (English)
----------------------------------------------------------------------------------------------




On Sat, Mar 13, 2010 at 10:24 PM, Faiz Rasool <fai...@gmail.com> wrote:

>  Hi Tal,
>
> I am typing:
>
> >birth =c(50,34)# frequencies of the two categories of the independent
> variable.
> >mental.health=c(28,26,30)#frequencies of the three categories of
> the dependent variable.
> >table(birth,mental.health)
> I get an error "all arguments must have the same length"
> when I use
> data.frame(birth,mental.health)
> I get "arguments imply differing number of rows."
>
>
> There is no missing value, and the sample size is 84.
>
> Best regards,
> Faiz.
>
> ----- Original Message -----
> *From:* Tal Galili <tal.gal...@gmail.com>
> *To:* Faiz Rasool <fai...@gmail.com>
> *Sent:* Sunday, March 14, 2010 1:04 AM
> *Subject:* Re: [R] Two questions, first about contingency tables, and
> second about table () and data.frame (), from a visually impaired user.
>
> Hi Faiz,
>
> Two ideas:
> 1) do you have any NA's ?
> 2) can you send an example of the code/ file?  That might help people (like
> me) to answer.
>
> Tal
>
> ----------------Contact
> Details:-------------------------------------------------------
> Contact me: tal.gal...@gmail.com |  972-52-7275845
> Read me: www.talgalili.com (Hebrew) | www.biostatistics.co.il (Hebrew) |
> www.r-statistics.com (English)
>
> ----------------------------------------------------------------------------------------------
>
>
>
>
> On Sat, Mar 13, 2010 at 9:58 PM, Faiz Rasool <fai...@gmail.com> wrote:
>
>> Hi all,
>>
>> I want  to make a contingency table in R. I want to tabulate two
>> variables, one as the independent and second as the dependent variable. The
>> IV has two categories, namely, birth complications, and no birth
>> complications. The frequency of birth complication category is fifty, and
>> the frequency of no birth complication category is 34. The categories and
>> frequencies of DV follows. Schizophrenic 28, depressed 26, normal 30. When I
>> am trying to make a contingency table in R, using table(name of variable
>> one,name of variable two), I am getting an error that all arguments must
>> have the same length. I believe that there would be two rows and three
>> columns according to categories of IV and DV, But I guess R wants a third
>> row for IV. When I am trying my luck with data.frame(var1,var2), I receive
>> an error "arguments imply differing number of rows". Any suggestion on how I
>> can make a contingency table using the data above?
>>
>> My second question is a result of my inability to see the screen. I want
>> to know that what is the difference between the tables you can make using
>> table () and data.frame (). When I think of a table in my mind, I think of
>> horizontal rows and vertical columns presenting data on different variables.
>> But I  am not sure what type of tables data.frame () prints on the screen
>> and what type of tables table () prints on the screen. and which function
>> should I use when I want to make  tables you are suppose to make in
>> statistics.
>>
>> Thank you all, and sorry for such basic questions.
>> faiz.
>>
>>
>>
>>
>>        [[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
>> and provide commented, minimal, self-contained, reproducible code.
>>
>
>

        [[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
and provide commented, minimal, self-contained, reproducible code.

Reply via email to