File: toDataFrame.Rd

package info (click to toggle)
r-cran-memisc 0.99.31.8.2%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 2,136 kB
  • sloc: ansic: 5,117; makefile: 2
file content (53 lines) | stat: -rw-r--r-- 2,014 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
\name{to.data.frame}
\alias{to.data.frame}
\title{Convert an Array into a Data Frame}
\description{
  \code{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.
}
\usage{
to.data.frame(X,as.vars=1,name="Freq")
}
\arguments{
  \item{X}{an array.}
  \item{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 \code{X} is a contingency table and the
    dimensional extents are named after the cross-classified factors.
    Takes effect only if \code{X} is 
    an atomic array. If \code{as.vars} equals zero, a new variable
    is created that contains the values of the array, that is,
    \code{to.data.frame} acts on the array \code{X}
    like \code{as.data.frame(as.table(X))}
    }
  \item{name}{a character string; the name of the variable
    created if \code{X} is an atomic array and \code{as.vars} equals zero.
    }
}

\value{
  A data frame.
}

\examples{
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")
}
\keyword{manip}