Displaying 20 results from an estimated 3000 matches similar to: "aperm() should retain class of input object"
2010 Dec 02
1
latex tables for 3+ dimensional tables/arrays
I'm looking for an R method to produce latex versions of tables for
table/array objects of 3 or more dimensions,
which, of necessity is flattened to a 2D display, for example with
ftable(), or vcd::structable, as shown below.
I'd be happy to settle for a flexible solution for the 3D case.
> UCB <- aperm(UCBAdmissions, c(2, 1, 3))
> ftable(UCB)
Dept A B
2009 Oct 11
3
Error in family$family : $ operator is invalid for atomic vectors
Dear List,
I'm having problem with an exercise from The R book (M.J. Crawley) on page
567.
Here is the entire code upto the point where I get an error.
data(UCBAdmissions)
x <- aperm(UCBAdmissions, c(2, 1, 3))
names(dimnames(x)) <- c("Sex", "Admit?", "Department")
ftable(x)
fourfoldplot(x, margin = 2)
dept<-gl(6,4)
sex<-gl(2,1,24)
2000 Jun 13
1
problem with aperm? (PR#568)
R version 1.0.1
OS RedHat Linux 6.1
In attempting to test for numeric vectors in a data frame, I tried:
apply(dataframe,2,is.numeric)
and found that it returned FALSE for all vectors whether they were
numeric or not. I tracked this to the fact that as.array() was
converting the data frame to character vectors, and thought I could
solve it by using array(), which preserved the mode of the
2010 Jul 29
1
Using 'dimname names' in aperm() and apply()
I think that the "dimname names" of tables and arrays could make
aperm() and apply() (and probably some other functions) easier to use.
(dimname names are, for example, created by table() )
The use would be something like:
--
x <-table( from=sample(3,100,rep=T), to=sample(5,100,rep=T))
trans <- x / apply(x,"from",sum)
y <- aperm( trans,
2004 Mar 10
3
aperm() and as.list() args to "["
Hi everyone.
I'm playing with aperm():
a <- 1:24
dim(a) <- c(2,3,2,2)
permutation <- c(1,2,4,3)
b <- aperm(a,permutation)
So if my understanding is right,
a[1,3,2,1] == b[c(1,3,2,1)[permutation] ]
but this isn't what I want because the RHS evaluates to a vector, and
I am trying to identify a single element of b.
How do I modify the RHS to give what I want?
Following
2014 Jan 10
0
proposal: stats::as.matrix.ftable method
Following some discussion on R-help, I'd like to propose that an
as.matrix method be added
to those available for ftable objects. The reason for this is that
there are a variety of situations
where one needs to flatten a 3+ way table, but then use that for
analysis as a matrix, not just for
pretty-printing. There is an as.table method to turn the result back to
a table, but an as.matrix
2012 Jan 26
1
ftable.formula
I apologize in advance if this is the wrong forum for this
report/request, and for the fact that I have not read the code for
ftable.formula in any detail.
>From reading the documentation for ftable.formula, I expected that the
following two calls to ftable would produce the same results:
data(UCBAdmissions)
ftable(UCBAdmissions, row.vars = "Dept", col.vars = c("Gender",
2001 Jul 10
0
speeding up aperm/ adding repmat
Hi,
I have noticed that aperm is very slow, and I wondered if there was a
way of speeding it up.
Let me tell you a bit about the context of my problem, because perhaps
I shouldn't be using aperm at all.
The context is probabilistic inference in
graphical models. One of the most fundamental operations is two
compute an element-wise multiplication of two arrays of different
sizes, say A and B.
2012 Dec 18
2
Changing Variable Names In VCD
Hello:
What is the most efficient way to change the plotted variable names in mosaic plots in the vcd package? Should one do a separate contingency table first, change the dimension names there and then pass that to mosaic?
Or is there a way to do it simply within mosaic.
I was thinking something like:
mosaic(~var1+var2, labelling_args=list(varnames=c('newvar1', 'newvar2'))
Simon
2005 Sep 16
1
How to make two figures in one plot - package vcd
Dear all,
I have a problem to make figures with two columns in package vcd.
Here an example code I take from "\library\vcd\html\plot.loglm.html"
What I need, I want to make two figures in one plot.
How could I do that.
I have tried with
layout(rbind(c(1, 1, 2, 2)))
but the same result, two plot.
Best wishes, Muhammad Subianto
library(vcd)
oldpar <- par(mfrow=c(1, 2))
## mosaic
2006 Feb 14
1
addmargins
> addmargins(UCBAdmissions, FUN = list(Total=sum))
works with no problems, but consider:
> myFUN <- list(Total=sum)
> addmargins(UCBAdmissions, FUN = myFUN)
Error in "names<-.default"(`*tmp*`, value = "") :
names() applied to a non-vector
Is this a bug?
> R.version
_
platform i386-pc-mingw32
arch i386
os mingw32
system
2007 Feb 24
1
Woolf's test, Odds ratio, stratification
Just a general question concerning the woolf test (package vcd), when we have
stratified data (2x2 tables) and when the p.value of the woolf-test is
below 0.05 then we assume that there is a heterogeneity and a common odds
ratio cannot be computed?
Does this mean that we have to try to add more stratification variables
(stratify more) to make the woolf-test p.value insignificant?
Also in the
2008 Nov 30
1
normal-bracket50bracket-normal?
Hello:
I've found structures like "normal-bracket50bracket-normal" in
help files for R packages including the following:
* "mergeprepare" and "mergematrices" in a document dated
March 3, 2004 by Richard Mott; the second contains
"normal-bracket30bracket-normal".
* "Fperm.fd" and "tperm.fd" in the
2002 Jan 30
1
mosaicplot(formula, data)--- bugged?
I have been tinkering with mosaicplot() and friends as a way
of learning R. As part of this, I've written a pair.table()
method for mosaic matrices, and would like to extend mosaicplot
to work with loglin and logln (MASS) objects. I'm using
R 1.4.0 on Win 98.
I've been trying to figure out the formula interface, and think
there's a bug, but not sure how to find it, yet alone fix
2017 Sep 28
2
building random matrices from vectors of random parameters
Sure -- thanks -- only took me 3-4 attempts to get aperm to work (as
opposed to really thinking hard about how it works ;-)
On 9/28/2017 11:55 AM, Duncan Murdoch wrote:
> On 28/09/2017 9:10 AM, Evan Cooch wrote:
>> Thanks for both the mapply and array approaches! However, although
>> intended to generate the same result, they don't:
>>
>> # mapply approach
2013 Jul 04
1
Modificar una función de un paquete
Muchas gracias Javier,
Lo que yo quiero es cambiar el título de la leyenda que dice "Pearson
residuals" a español "Residuales de Pearson", pero no me doy cuenta como.
También en lugar de "p-value", que diga "Valor de P". Es posible?
Manuel
2013/7/4 Marcuzzi, Javier Rubén <javier.ruben.marcuzzi@gmail.com>
> Estimado Manuel Spíndola
>
>
2006 Jun 09
1
Idempotent apply
Dear all,
I have been working on an idempotent version of apply, such that
applying a function f(x) = x (ie. force) returns the same array (or a
permutation of it depending on the order of the margins):
a <- array(1:27, c(2,3,4))
all.equal(a, iapply(a, 1, force))
all.equal(a, iapply(a, 1:2, force))
all.equal(a, iapply(a, 1:3, force))
all.equal(aperm(a, c(2,1,3)), iapply(a, 2, force))
2017 Sep 28
0
building random matrices from vectors of random parameters
The use of aperm is unnecessary if you call array() properly.
ms <- array(c(rep(0, 5),so,sa*m,sa), c(5, 2, 2))
--
Sent from my phone. Please excuse my brevity.
On September 28, 2017 9:10:26 AM PDT, Evan Cooch <evan.cooch at gmail.com> wrote:
>Sure -- thanks -- only took me 3-4 attempts to get aperm to work (as
>opposed to really thinking hard about how it works ;-)
>
>On
2011 Mar 30
4
fonts in mosaic
I need to change the font(s) used in mosaic from package vcd.
The help file and the vignette do not give very explicit examples for
doing that.
The easiest solution would be changing the font for everything
on the graph: var labels, var names, title, subtitle, and cell labels.
What is the easiest way of accomplishing this?
2011 Feb 16
1
Saturated model in binomial glm
Hi all,
Could somebody be so kind to explain to me what is the saturated model
on which deviance and degrees of freedom are calculated when fitting a
binomial glm?
Everything makes sense if I fit the model using as response a vector of
proportions or a two-column matrix. But when the response is a factor
and counts are specified via the "weights" argument, I am kind of lost
as far as