to.data.frame | R Documentation |
to.data.frame
converts an array into a data frame, in such a way
that a chosen dimensional extent forms variables in the data frame.
The elements of the array must be either atomic, data frames
with matching variables, or coercable into such data frames.
to.data.frame(X,as.vars=1,name="Freq")
X |
an array. |
as.vars |
a numeric value or a character string.
If it is a numeric value then it indicates the dimensional extend
which defines the variables. If it is a character string then it is
matched against the names of the dimenstional extents. This is
applicable e.g. if |
name |
a character string; the name of the variable
created if |
A data frame.
berkeley <- Aggregate(Table(Admit,Freq)~.,data=UCBAdmissions)
berktest1 <- By(~Dept+Gender,
glm(cbind(Admitted,Rejected)~1,family="binomial"),
data=berkeley)
berktest2 <- By(~Dept,
glm(cbind(Admitted,Rejected)~Gender,family="binomial"),
data=berkeley)
Stest1 <- Lapply(berktest2,function(x)predict(x,,se.fit=TRUE)[c("fit","se.fit")])
Stest2 <- Sapply(berktest2,function(x)coef(summary(x)))
Stest2.1 <- Lapply(berktest1,function(x)predict(x,,se.fit=TRUE)[c("fit","se.fit")])
to.data.frame(Stest1)
to.data.frame(Stest2,as.vars=2)
to.data.frame(Stest2.1)
# Recasting a contingency table
to.data.frame(UCBAdmissions,as.vars="Admit")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.