Displaying 20 results from an estimated 20000 matches similar to: "RFC: tapply(*, ..., init.value = NA)"
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
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 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 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
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:
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
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
2007 Nov 06
1
A suggestion for an amendment to tapply
Dear R-developers,
when tapply() is invoked on factors that have empty levels, it returns
NA. This behaviour is in accord with the tapply documentation, and is
reasonable in many cases. However, when FUN is sum, it would also
seem reasonable to return 0 instead of NA, because "the sum of an
empty set is zero, by definition."
I'd like to raise a discussion of the possibility of an
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).
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)),
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"
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
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
2012 Sep 14
1
parallel version of tapply() or table()?
Hello R-helpers.
I've tried to recreate a parallel version of tapply() and table() using a combination of the parallel functions mclapply() and pvec() and papply(), but haven't been successful. In the end, I'm trying to get a cross tab of two vectors. I currently (can) use tapply(..., sum) and table(), and even xtabs() and ftable(), but with tens of millions of words and tens of
2010 Sep 10
4
Counting occurances of a letter by a factor
I'm trying to find a more elegant way of doing this. What I'm trying to accomplish is to count the frequency of letters (major / minor alleles) in a string grouped by the factor levels in another column of my data frame.
Ex.
> DF<-data.frame(c("CC", "CC", NA, "CG", "GG", "GC"), c("L", "U", "L",
2008 Sep 28
2
using tapply on a data frame in a function
Hello,
I'm trying to use tapply to find group means in a function. It works
outside of a function, but I get the error message from the following code:
"Error in tapply(index, cluster, mean) : arguments must have same length."
Any suggestions? Thanks.
eric
d <- data.frame(cbind(cluster=1:2, value1=1:10, value2=11:20))
d
FindClusterTraits <- function(framename, index){
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.
--------------------------------------------
2004 May 10
7
strange behavior of names<-
Dear R-help,
I've encounter what seems to me a strange problem with "names<-". Suppose I
define the function:
fun <- function(x, f) {
m <- tapply(x, f, mean)
ans <- x - m[match(f, unique(f))]
names(ans) <- names(x)
ans
}
which subtract out the means of `x' grouped by `f' (which is the same as,
e.g., resid(lm(x~f)) if `f' is a factor).