That function, expand.dft is in the vcdExtra package
On 6/15/2016 12:42 PM, Marc Schwartz wrote:
There is a function called expand.dft(), which I posted some years ago, which
is a modification of a prior version, posted a few years before that.
The updated version is here:
https://stat.et
Thank you all,
David's solution is the one that matches my taste the most.
Patrizio
On Wed, Jun 15, 2016 at 8:04 PM, David L Carlson wrote:
> After converting the table to a data frame, replicate each row by the
> number of observations:
>
> > ddd.df <- as.data.frame(ddd) # as.data.frame.table
After converting the table to a data frame, replicate each row by the number of
observations:
> ddd.df <- as.data.frame(ddd) # as.data.frame.table does the same thing
> ddd.new <- as.matrix(ddd.df[rep(seq_along(ddd.df[, 1]), ddd.df$Freq), 1:2])
> head(ddd.new)
a b
1 "a" "A"
1.1 "a" "A"
> On Jun 15, 2016, at 11:10 AM, Patrizio Frederic
> wrote:
>
> Dear R-users,
> I've a problem that puzzle me
>
> suppose I have a two way contigency table
>
> a <- sample(al <- letters[1:10],100,T)
> b <- sample(bl <- LETTERS[1:5],100,T)
> ab <- cbind(a,b)
>
> ddd <- (xtabs(data = ab))
> dd
Em Qua 15 jun. 2016, às 13:10, Patrizio Frederic escreveu:
> Dear R-users,
> I've a problem that puzzle me
>
> suppose I have a two way contigency table
>
> a <- sample(al <- letters[1:10],100,T)
> b <- sample(bl <- LETTERS[1:5],100,T)
> ab <- cbind(a,b)
>
> ddd <- (xtabs(data = ab))
> ddd <- a
Hi Patrizio,
maybe there is a more efficient way, but you can loop over rows and columns
like this
ab.recon <- data.frame()
ddd.rownames <- rownames(ddd)
ddd.colnames <- colnames(ddd)
for(cur.row in ddd.rownames){
for(cur.col in ddd.colnames){
times.found <- ddd[cur.row, cur.col]
tmp.
6 matches
Mail list logo