Displaying 20 results from an estimated 20000 matches similar to: "apply() function: margin argument: "2L" versus "2""
2012 Sep 06
1
Change margin size of complex barplot
Dear R-help members,
with the help of one of you the following R-Code was developed. No I have the (probably simple) problem that I want to increase font size of "text" and "ylab" names from 1 to 2. Unfortunately I'm not able to adjust the margin so, that the plot is appers complete (all names readable) on a 8:14 Inch scale plot.
Some times I get the error message that
2004 Aug 31
2
Dimension of apply(X, MARGIN, FUN) when FUN returns a matrix
Dear all,
apply(X, MARGIN, FUN, ...) returns an array of dimension
c(n, dim(X)[MARGIN]) when FUN returns a vector of length n > 1.
Matrices and arrays are also vectors, so if FUN returns a matrix or an
array, apply returns an array of dimension c(n, dim(X)[MARGIN]) as
above. This is in accordance with the description of apply in the
Blue Book, and also how Splus works (at least v6.0).
I am
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,
2013 Jul 01
1
dotchart.R and left margin
Hello,
In trying to minimize the margin on the left hand side when using
dotchart I found what may be a typo in the code.
In the lines below from dotchart.R, should nmai[4L] be nmai[2L]?
if (!(is.null(labels) && is.null(glabels))) {
nmai <- par("mai")
nmai[2L] <- nmai[4L] + max(linch + goffset, ginch) + 0.1
par(mai = nmai)
}
Thank you,
Stephen Weigand
--
2009 Dec 16
1
difference between the meaning of MARGIN in sweep() and apply()
For example, subtracting 1:2 from the rows of a two-column matrix:
> t(apply(matrix(1:6,ncol=2),MARGIN=1,function(y) y - 1:2))
[,1] [,2]
[1,] 0 2
[2,] 1 3
[3,] 2 4
> sweep(matrix(1:6,ncol=2),MARGIN=2,1:2,FUN="-")
[,1] [,2]
[1,] 0 2
[2,] 1 3
[3,] 2 4
Is there a logic to this difference, or is it just a quirk of the history of
these
2004 Sep 09
3
function "apply" and 3D arrays (PR#7221)
Full_Name: jarek tuszynski
Version: 1.8.1
OS: windows 2000
Submission from: (NULL) (198.151.13.10)
Example code:
> a=array(1:27, c(3,3,3))
> apply(a,2, var)
[,1] [,2] [,3]
[1,] 1 1 1
[2,] 1 1 1
[3,] 1 1 1
[4,] 1 1 1
[5,] 1 1 1
[6,] 1 1 1
[7,] 1 1 1
[8,] 1 1 1
[9,] 1 1 1
> apply(a,2, mean)
[1]
2007 Jan 16
1
curious about dimension of 'apply' output when MARGIN=1
Reading the documentation for 'apply', I understand the following is
working exactly as documented:
> M<-matrix(1:6,ncol=2)
> M
[,1] [,2]
[1,] 1 4
[2,] 2 5
[3,] 3 6
> apply(M,2,function(column) column+c(1,2,3))
[,1] [,2]
[1,] 2 5
[2,] 4 7
[3,] 6 9
> apply(M,1,function(row) row+c(1,2))
[,1] [,2] [,3]
[1,] 2 3 4
2005 Dec 07
1
Dots argument in apply method
Hello everyone,
I'm working on a package using S4 classes and methods and I ran into the
following "problem" when I tried to create an "apply" method for objects
of one of my new classes. I've found a way around the problem but I
wonder if I did not paint myself into the corner. I'd like your opinion
about that.
So I have an object "myObj" of class
2007 Nov 02
1
res_mysql versus res_odbc
2020 May 22
2
Compatibility issues caused by new simplify argument in apply function
Interesting problem. I'm very rusty on S4 but would one solution be
to, already now, add 'simplify = TRUE' to the S4 method and document
it;
setMethod("apply", signature(X = "Speclib"),
function(X,
FUN,
bySI = NULL,
...,
simplify = TRUE) {
?
Henrik
On Fri, May 22, 2020 at 6:26
2009 Jul 07
6
Uncorrelated random vectors
Hello,
is it possible to create two uncorrelated random vectors for a given distribution.
In fact, I would like to have something like the function "rnorm" or "rlogis" with the extra property that they are uncorrelated.
Thanks for your help,
Luba
[[alternative HTML version deleted]]
2020 May 22
3
Compatibility issues caused by new simplify argument in apply function
Dear R Developers,
the new simplify argument in apply causes that my package (hsdar) does not
pass the
checks in R-devel.
The workaround, Kurt Hornik send me, is working for the R-code:
if("simplify" %in% names(formals(base::apply)))
do something
else
do something else
Unfortunately, I cannot conditionalize the man pages of the functions. I get
the message
that
2009 Jul 20
3
Another SEM question
Hello,
I use the function sem the following way
sem.mod <- sem(model, mod.cov, N=109) where the variables are modelled:
Z -> M
Z -> I
Z -> R
M <-> M
I <-> I
R <-> R
Z <-> Z
The output is
...
Normalized Residuals
Min. 1st Qu. Median Mean 3rd Qu. Max.
-7.3300 -0.2750 -0.2670 -0.1290 -0.0369 9.0300
Parameter Estimates
Estimate Std Error z value Pr(>|z|)
2018 Jul 02
1
MARGIN in base::unique.matrix() and base::unique.array()
Hi,
The man page for base::unique.matrix() and base::unique.array() says
that MARGIN is expected to be a single integer. OTOH the code in charge
of checking the user supplied MARGIN is:
if (length(MARGIN) > ndim || any(MARGIN > ndim))
stop(gettextf("MARGIN = %d is invalid for dim = %d",
MARGIN, dx), domain = NA)
which doesn't really make sense.
As
2009 Jul 29
1
Similar package like SEM
Hello,
is there a similar package like SEM. In fact, I am looking for a package where I as input several given vector variables which are part of an autoregressive model.
Then I would like to obtan parameters for so called latent variables.
Thank you,
Luba
[[alternative HTML version deleted]]
2008 Sep 25
1
Proper use of jitter-buffer "margin" parameter.
Hi,
We've been having mixed success (mostly good) with the jitter-buffer,
and I'm trying to understand what my options are for tuning JB
parameters to our particular use-case.
In what may become a series of emails, my first question is how to
properly set the margin parameter.
I have set up a test harness that allows me to synthesize arbitrary
sequences of puts/gets, so that I can test
2008 Jul 02
1
is there an equivalent of prop.table but for counts
I have a simple table below called temptable and i want to obtain the
same structure that prop.table creates except get the counts
rather than the proportions. margin.table seems to create one table with
columns and rows whereas I am looking for the three table
type structure that prop.table gives. Thanks.
temptable<-structure(c(0L, 2L, 0L, 1L, 0L, 0L, 0L, 0L, 0L, 1L, 0L, 0L,
0L,
0L, 0L,
2001 Jul 02
1
margin.table
Hello all,
I was wondering if the following behaviour of margin.table in R 1.3.0 is normal.
> mm <- data.frame(x=c(0,0,1), y=c(1,1,0), z=c(0,1,0))
> margin.table(mm,1)
[1] 1 2 3
<0 rows> (or 0-length row.names)
while using 'apply(x,margin,sum)' I get
> apply(mm,1,sum)
1 2 3
1 2 1
which appears to be normal. Similar behaviour when margin=2.
On the other hand, the
2008 May 02
1
axis 1 and axis 2 margin
Hi,
I am using axis() to plot axis 1 and axis 2. but now when I used
axis(side=1,....) and axis(side=2,.....), there's a big margin between these
two axis. does anybody have any idea about how to shrink the margin between
these two axis. basically, I want to move axis 1 left so that when I plot
axis 3, the margin between axis 1 and 2 and margin between axis 1 and 4 are
the same. like this
2009 Jul 30
1
package lattice can't be loeaded
I try to load the package lattice by library(lattice).
Although I have installed it through CRAN by internet as well as from a local directory using the zip-file, it can't be loaded into the editor.
Can anyone give advice, please.
I am using R 2.9.1 on Widows XP.
Thanks a lot,
Luba
[[alternative HTML version deleted]]