Incidentally, the feature becomes really powerful when one uses
functions such as addmargins together with prop.table as in
coinf.table <-as.matrix(coinfection)
prop.table(coinf.table,1) # to see proportions from each HPV type per study
addmargins(coinf.table)# to see totals within study and accr
Genius! Thank you very much.
Yes indeed I should have thought of that. For some reason I have a
mental blank about the use of row.names and instead I repeatedly put
that kind of data as a column in the data frame. Thank you for the
rescue.
__
R-help@r-pr
On 10/3/07, Farrel Buchinsky <[EMAIL PROTECTED]> wrote:
> Thank you. It comes close but not exactly what I wanted. I had to
> scrap my column that contained character values. That column noted the
> name of the study. Let me try show you here
>
> Best if viewed in courier font
>
> > coinfection
>
No. Not really.What you have done seems to be similar to what I could do
with the reshape library.
rawer<-melt(coinfection,id.var="study") # please refer to my post
immediately before this.
I am still unable to make use of prop.table and margin.table functions.
On 10/3/07, Deepayan Sarkar <[EMAIL
Thank you. It comes close but not exactly what I wanted. I had to
scrap my column that contained character values. That column noted the
name of the study. Let me try show you here
Best if viewed in courier font
> coinfection
study HPV6 HPV11 CoInfect other
1 Wiatrak 2004 3123
On 10/3/07, Farrel Buchinsky <[EMAIL PROTECTED]> wrote:
> Your solution would work if the data frame contained the raw data. In that
> case the table function as you outlined would be a table crossing all the
> levels of column 1 with all the levels of column 2.
> Instead my data frame is the table
I think that what you need to do is
as.table(as.matrix(dff))
E.g.
melvin <- data.frame(x=c(3,1,3,2),y=c(3,3,4,5))
clyde <- as.table(as.matrix(melvin))
prop.table(clyde,1)
x y
A 0.500 0.500
B 0.250 0.750
C 0.4285714 0.5714286
Your solution would work if the data frame contained the raw data. In that
case the table function as you outlined would be a table crossing all the
levels of column 1 with all the levels of column 2.
Instead my data frame is the table. It is an aggregate table (I may be using
the wrong buzzwords h
--- Farrel Buchinsky <[EMAIL PROTECTED]> wrote:
> How do you create a table from a data frame? I tried
> as.table(
> name.of.data.frame) but it bombed out.
> I will include the exact error message in my next
> posting. If I recall
> correctly, it said that the data.frame could not be
> coerced to
How do you create a table from a data frame? I tried as.table(
name.of.data.frame) but it bombed out.
I will include the exact error message in my next posting. If I recall
correctly, it said that the data.frame could not be coerced to a table.
On 10/2/07, John Kane <[EMAIL PROTECTED]> wrote:
>
>
What am I missing here?
Cannot you just create the table from the data.frame
and apply prop.table()to it?
--- Farrel Buchinsky <[EMAIL PROTECTED]> wrote:
> When one has raw data it is easy to create a table
> of one variable against
> another and then calculate proportions
> For example
> a.nice
When one has raw data it is easy to create a table of one variable against
another and then calculate proportions
For example
a.nice.table<-table(a,b)
prop.table(a.nice.table,1)
However, I looked at several papers and created a data frame of the
aggregate data. That means I acually created a table
12 matches
Mail list logo