Displaying 20 results from an estimated 10000 matches similar to: "A suggestion for an amendment to tapply"
2001 Nov 29
0
a patch to tapply (PR#1186)
Though tapply(x, factor, fun, simplify =TRUE) should be equivalent to
sapply(split(x, factor), fun, simplify=TRUE), note simplify=TRUE, it is not
so if fun() returns a vector rather than a scalar, e.g.
> tapply(1:6, c(0,0,0,1,1,1), function(x) c(min=min(x), max=max(x)),
simplify=TRUE)
$"0"
min max
1 3
$"1"
min max
4 6
> sapply(split(1:6, c(0,0,0,1,1,1)),
2008 Apr 15
1
by inconsistently strips class - with fix
summary:
The function 'by' inconsistently strips class from the data to which
it is applied.
quick reason:
tapply strips class when simplify is set to TRUE (the default) due to
the class stripping behaviour of unlist.
quick answer:
This can be fixed by invoking tapply with simplify=FALSE, or changing
tapply to use do.call(c instead of unlist
executable example:
1997 Dec 08
3
R-alpha: Bug in tapply in the Windows version of September
The function tapply is not working in the Windows version of R=20
(Version 0.50 Beta (Sept 29, 1997))
In
tapply <- function (x, INDEX, FUN=3DNULL, simplify=3DTRUE, ...)=20
...
The part:
if (simplify && all(unlist(lapply(ans, length)) =3D=3D 1)) {
ans <- unlist(ans, recursive =3D FALSE)
names(ans)<-namelist[[1]]
return(ans)
}
should be replaced by
if (simplify
2017 Jan 27
1
RFC: tapply(*, ..., init.value = NA)
On Fri, Jan 27, 2017 at 12:34 AM, Martin Maechler
<maechler at stat.math.ethz.ch> wrote:
>
> > On Jan 26, 2017 07:50, "William Dunlap via R-devel" <r-devel at r-project.org>
> > wrote:
>
> > It would be cool if the default for tapply's init.value could be
> > FUN(X[0]), so it would be 0 for FUN=sum or FUN=length, TRUE for
>
2017 Jan 27
1
RFC: tapply(*, ..., init.value = NA)
The "no factor combination" case is distinguishable by 'tapply' with simplify=FALSE.
> D2 <- data.frame(n = gl(3,4), L = gl(6,2, labels=LETTERS[1:6]), N=3)
> D2 <- D2[-c(1,5), ]
> DN <- D2; DN[1,"N"] <- NA
> with(DN, tapply(N, list(n,L), FUN=sum, simplify=FALSE))
A B C D E F
1 NA 6 NULL NULL NULL NULL
2 NULL NULL 3 6
2017 Jan 26
2
RFC: tapply(*, ..., init.value = NA)
On a related note, the storage mode should try to match ans[[1]] (or
unlist:ed and) when allocating 'ansmat' to avoid coercion and hence a full
copy.
Henrik
On Jan 26, 2017 07:50, "William Dunlap via R-devel" <r-devel at r-project.org>
wrote:
It would be cool if the default for tapply's init.value could be
FUN(X[0]), so it would be 0 for FUN=sum or FUN=length, TRUE
2017 Jan 26
3
RFC: tapply(*, ..., init.value = NA)
Last week, we've talked here about "xtabs(), factors and NAs",
-> https://stat.ethz.ch/pipermail/r-devel/2017-January/073621.html
In the mean time, I've spent several hours on the issue
and also committed changes to R-devel "in two iterations".
In the case there is a *Left* hand side part to xtabs() formula,
see the help page example using 'esoph',
it
2017 Jan 26
0
RFC: tapply(*, ..., init.value = NA)
It would be cool if the default for tapply's init.value could be
FUN(X[0]), so it would be 0 for FUN=sum or FUN=length, TRUE for
FUN=all, -Inf for FUN=max, etc. But that would take time and would
break code for which FUN did not work on length-0 objects.
Bill Dunlap
TIBCO Software
wdunlap tibco.com
On Thu, Jan 26, 2017 at 2:42 AM, Martin Maechler
<maechler at stat.math.ethz.ch> wrote:
2017 Jan 27
0
RFC: tapply(*, ..., init.value = NA)
> On Jan 26, 2017 07:50, "William Dunlap via R-devel" <r-devel at r-project.org>
> wrote:
> It would be cool if the default for tapply's init.value could be
> FUN(X[0]), so it would be 0 for FUN=sum or FUN=length, TRUE for
> FUN=all, -Inf for FUN=max, etc. But that would take time and would
> break code for which FUN did not work on
2017 Jan 31
1
RFC: tapply(*, ..., init.value = NA)
Function 'aggregate.data.frame' in R has taken a different route. With drop=FALSE, the function is also applied to subset corresponding to combination of grouping variables that doesn't appear in the data (example 2 in https://stat.ethz.ch/pipermail/r-devel/2017-January/073678.html).
Because 'default' is used only when simplification happens, putting 'default' after
1999 Nov 11
2
tapply not simplifying to vector? (PR#320)
Hi, all.
The help file for tapply says that if simplify is true, and the result of
the calculation is always a scalar, then tapply will return a vector.
Nonetheless:
> t1 <- tapply(runif(10), rep(1:5, 2), mean)
> is.vector(t1)
[1] FALSE
> is.array(t1)
[1] TRUE
>
I have found this in version 0.65.1 on an SGI running Irix 6.5, and on a
Mac running Linux-PPC. I've also
2008 Jan 27
1
tapply on empty data.frames (PR#10644)
Full_Name: Hilmar Berger
Version: 2.4.1/2.6.2alpha
OS: WinXP
Submission from: (NULL) (84.185.128.110)
Hi all,
If I use tapply on an empty data.frame I get an error. I'm not quite sure if one
can actually expect the function to return with a result. However, the error
message suggests that this case does not get handled well.
This happens both in R-2.4.1 and 2.6.2alpha (version 2008-01-26).
2010 Oct 28
1
Unexpected behabiour of min, tapply and POSIXct/POSIXlt classes?
Hello,
I found rather surprising the behaviour of POSIXct and POSIXlt classes
when combined with min and tapply.
The details can be deduced from the script below:
############# Start of the script ####################
before <- Sys.time()
Sys.sleep( 1 )
now1 <- now2 <- Sys.time()
my.times <- c( before, now1, now2 )
class( my.times ) ## [1] "POSIXct"
2004 Apr 08
1
Why are Split and Tapply so slow with named vectors, why is a for loop faster than mapply
First, here's the problem I'm working on so you understand the context. I
have a data frame of travel activity characteristics with 70,000+ records.
These activities are identified by unique chain numbers. (Activities are
part of trip chains.) There are 17,500 chains.
I use the chain numbers as factors to split various data fields into lists
of chain characteristics with each element of
2017 Feb 01
1
RFC: tapply(*, ..., init.value = NA)
On 'aggregate data.frame', the URL should be https://stat.ethz.ch/pipermail/r-help/2016-May/438631.html .
vector(typeof(ans))
(or vector(storage.mode(ans)))
has length zero and can be used to initialize array.
Instead of
if(missing(default)) ,
if(identical(default, NA))
could be used. The documentation could then say, for example: "If default = NA (the default), NA of appropriate
1997 Aug 19
2
R-alpha: A few bugs in R-0.50-a3.
A few problems in R-0.50-a3 (which were also in R-0.49):
1)
y <- c(10,11,12,13,14,NA,NA)
n <- length(y)
missed <- (1:n)[is.na(y)]
notmissed <- (1:n)[!is.na(y)]
blocks <- cut(missed,breaks=c(0,notmissed,n+1))
a <- function(v) {
q <- range(v)
c(q[1]-1,q[2]+1)
}
brackets <- tapply(missed,blocks,a)
This codes gives the following in S:
> brackets
$"0+ thru 1":
2017 Feb 07
0
RFC: tapply(*, ..., init.value = NA)
Function 'tapply' in R devel r72137 uses
if(!is.null(ans) && is.na(default) && is.atomic(ans)) .
Problems:
- It is possible that user-specified 'default' is not of length 1. If the length is zero, the 'if' gives an error.
- It is possible that is.na(default) is TRUE and user-specified 'default' is NaN.
--------------------------------------------
2017 Jan 25
3
Undefined behavior of head() and tail() with n = 0
Hi all,
The documentation for head() and tail() describes the behavior of
these generic functions when n is strictly positive (n > 0) and
strictly negative (n < 0). How these functions work when given a zero
value is not defined.
Both GNU command-line utilities head and tail behave differently with +0 and -0:
http://man7.org/linux/man-pages/man1/head.1.html
1999 Feb 19
1
Potential problem with tapply
Is the following behaviour of tapply not disappointing?
Problem with tapply occurs when dealing with na.rm when an
argument additional to na.rm is sent to the applied function (here
quantile).
Any comment?
Thank you,
Philippe Lambert
> x <- c(12,10,12,2,4,11,3,7,2,1,18,7,NA,NA,7,5)
> fac <- gl(4,4,16)
> # Works fine
> tapply(x,fac,quantile,na.rm=T)
$"1"
0% 25%
2007 Sep 13
1
Collapsing data frame; aggregate() or better function?
Hello r-help,
I am trying to collapse or aggregate 'some' of a data frame. A very
simplified version of my data frame looks like:
> tester
trip set num sex lfs1 lfs2
1 313 15 5 M 2 3
2 313 15 3 F 1 2
3 313 17 1 M 0 1
4 313 17 2 F 1 1
5 313 17 1 U 1 0
And I want to omit sex from the picture and just get an addition of num,