Displaying 18 results from an estimated 18 matches for "ansmat".
2017 Jan 26
3
RFC: tapply(*, ..., init.value = NA)
...<- if (!is.null(FUN)) match.fun(FUN)
if (!is.list(INDEX)) INDEX <- list(INDEX)
@@ -44,7 +44,7 @@
index <- as.logical(lengths(ans)) # equivalently, lengths(ans) > 0L
ans <- lapply(X = ans[index], FUN = FUN, ...)
if (simplify && all(lengths(ans) == 1L)) {
- ansmat <- array(dim = extent, dimnames = namelist)
+ ansmat <- array(init.value, dim = extent, dimnames = namelist)
ans <- unlist(ans, recursive = FALSE)
} else {
ansmat <- array(vector("list", prod(extent)),
-----------------------------------------------------------------...
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 for
FUN=all...
1999 Nov 11
2
tapply not simplifying to vector? (PR#320)
...lts that I expected to be vectors couldn't
be combined into a data frame (Error: can't coerce array into a
data.frame).
It seems that the check and conversion simply never happens. One way to
fix this is to simply add these few lines to the end of the function (just
before the value "ansmat" is returned:
if(length(dim(ansmat)) == 1){
dim(ansmat) <- NULL
names(ansmat) <- namelist[[1]]
}
I wouldn't be surprised to find that there's a more elegant way to do
this. Perhaps ansmat[index] should be returned instead of ansmat? But I
haven't tested this...
2008 Apr 15
1
by inconsistently strips class - with fix
...<- group + ngroup * (as.integer(index) - one)
ngroup <- ngroup * nlevels(index)
}
if (is.null(FUN))
return(group)
ans <- lapply(split(X, group), FUN, ...)
index <- as.integer(names(ans))
if (simplify && all(unlist(lapply(ans, length)) == 1)) {
ansmat <- array(dim = extent, dimnames = namelist)
<<<<
ans <- unlist(ans, recursive = FALSE)
====
ans <- do.call(c, ans, recursive = FALSE)
>>>>
}
else {
ansmat <- array(vector("list", prod(extent)), dim = extent,
dimnames = n...
2001 Nov 29
0
a patch to tapply (PR#1186)
...N))
return(group)
ans <- lapply(split(X, group), FUN, ...)
if (simplify && length(common.len <- unique(unlist(lapply(ans, length))))
== 1) {
if (common.len > 1) {
extent <- c(common.len, extent)
namelist <- c(list(names(ans[[1]])), namelist)
}
ansmat <- array(unlist(ans, recursive = FALSE), dim = extent, dimnames =
namelist)
return(ansmat)
}
index <- as.numeric(names(ans))
ansmat <- array(vector("list", prod(extent)), dim = extent,
dimnames = namelist)
names(ans) <- NULL
ansmat[index] <-...
2007 Nov 06
1
A suggestion for an amendment to tapply
...index)
group <- group + ngroup * (as.integer(index) - one)
ngroup <- ngroup * nlevels(index)
}
if (is.null(FUN)) return(group)
ans <- lapply(split(X, group), FUN, ...)
index <- as.numeric(names(ans))
if (simplify && all(unlist(lapply(ans, length)) == 1)) {
ansmat <- array(dim=extent, dimnames=namelist)
ans <- unlist(ans, recursive = FALSE)
}
else {
ansmat <- array(vector("list", prod(extent)),
dim=extent, dimnames=namelist)
}
## old : ansmat[as.numeric(names(ans))] <- ans
names(ans) <- NULL
ansmat[index...
2017 Jan 27
1
RFC: tapply(*, ..., init.value = NA)
...ged.
>
>>>>>> Henrik Bengtsson <henrik.bengtsson at gmail.com>
>>>>>> on Thu, 26 Jan 2017 07:57:08 -0800 writes:
>
> > 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.
>
> Yes, related indeed; and would fall "in line" with Bill's idea.
> OTOH, it could be implemented independently,
> by something like
>
> if(missing(init.value))
> init.value <-
> if...
2008 Jan 27
1
tapply on empty data.frames (PR#10644)
...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).
> z = data.frame(a = c(1,2,3,4),b=c("a","b","c","d"))
> z1 = subset(z,a == 5)
> tapply(z1$a,z1$b,length)
Error in ansmat[index] <- ans :
incompatible types (from NULL to logical) in subassignment type fix
Deleting unused factor levels from the group parameter gives:
> tapply(z1$a,factor(z1$b),length)
logical(0)
Regards,
Hilmar
platform i386-pc-mingw32
arch i386...
2017 Jan 27
1
RFC: tapply(*, ..., init.value = NA)
...<- if (!is.null(FUN)) match.fun(FUN)
if (!is.list(INDEX)) INDEX <- list(INDEX)
@@ -44,7 +44,7 @@
index <- as.logical(lengths(ans)) # equivalently, lengths(ans) > 0L
ans <- lapply(X = ans[index], FUN = FUN, ...)
if (simplify && all(lengths(ans) == 1L)) {
- ansmat <- array(dim = extent, dimnames = namelist)
+ ansmat <- array(init.value, dim = extent, dimnames = namelist)
ans <- unlist(ans, recursive = FALSE)
} else {
ansmat <- array(vector("list", prod(extent)),
-----------------------------------------------------------------...
2017 Jan 27
0
RFC: tapply(*, ..., init.value = NA)
...pply()
would remain unchanged.
>>>>> Henrik Bengtsson <henrik.bengtsson at gmail.com>
>>>>> on Thu, 26 Jan 2017 07:57:08 -0800 writes:
> 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.
Yes, related indeed; and would fall "in line" with Bill's idea.
OTOH, it could be implemented independently,
by something like
if(missing(init.value))
init.value <-
if(length(ans)) as.vector(NA, mode=storage.mo...
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 26
0
RFC: tapply(*, ..., init.value = NA)
...UN)
> if (!is.list(INDEX)) INDEX <- list(INDEX)
> @@ -44,7 +44,7 @@
> index <- as.logical(lengths(ans)) # equivalently, lengths(ans) > 0L
> ans <- lapply(X = ans[index], FUN = FUN, ...)
> if (simplify && all(lengths(ans) == 1L)) {
> - ansmat <- array(dim = extent, dimnames = namelist)
> + ansmat <- array(init.value, dim = extent, dimnames = namelist)
> ans <- unlist(ans, recursive = FALSE)
> } else {
> ansmat <- array(vector("list", prod(extent)),
>
> ------------------...
2004 Nov 02
0
how to call function in ../src/main
...printf "result: $temp \n";
}
test();
It works fine.
But it looks not for calling functions in R/R-1.9.1/src/main
We want to correlation only, so we copy cov.c to cor.c
where use
cor ( int n, double *x, double *y, double *ans ) {
Rboolean cor, kendall, pair, na_fail, sd_0;
int ansmat, method, ncx, ncy;
/* compute correlations if PRIMVAL(op) == 0,
covariances if PRIMVAL(op) != 0 */
cor = 0;
ansmat = 0;
ncx = 1;
ncy = 1;
pair = TRUE;
kendall = FALSE;
cov_pairwise2(n, ncx, ncy, x, y, ans,
&sd_0, cor, kendall);
}...
2010 Oct 28
1
Unexpected behabiour of min, tapply and POSIXct/POSIXlt classes?
...a b
## 1288284737 1288284780
## Where did my POSIXct class go?
my.times.lt <- as.POSIXlt( my.times )
min( my.times.lt ) ## [1] "2010-10-28 18:52:17 CEST"; good!
tapply( my.times.lt, my.period, min )
# $a
# [1] 17.449
#
# $b
# [1] 52
#
# Mensajes de aviso perdidos
# In ansmat[index] <- ans :
# n?mero de items para para sustituir no es un m?ltiplo de la
longitud del reemplazo
#
# ?? :(
############# End of the script ####################
Here are the details of my session (as reported by sessionInfo):
R version 2.12.0 (2010-10-15)
Platform: i386-pc-mingw32/i386...
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
2017 Jan 31
1
RFC: tapply(*, ..., init.value = NA)
...;>>> Henrik Bengtsson <henrik.bengtsson at gmail.com> on
>>>>>>> Thu, 26 Jan 2017 07:57:08 -0800 writes:
>>
>> > 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.
>>
>> Yes, related indeed; and would fall "in line" with Bill's
>> idea. OTOH, it could be implemented independently, by
>> something like
>>
>> if(missing(in...
1999 Jan 17
1
Other core dumps, with apologies
...re dumped if it was used
> as
>
> tapply(x,listOfFactors,vectorReturningFunction)
>
> My naive solution was :
>
> j <- tapply(x, listOfFactors) # get the product factor
> answer <- tapply(x,j,vectorReturningFunction)
> .... CODE TO GET THE LABELS RIGHT ....
> ansmat <- array(unlist(answer), dim=someStuff,
> dimnames=otherStuff))
>
>
> The 'flexibility' of being passed back different structures
> (list, vector, matrix) depending upon the input structures
> somewhat complicates the explanation of the functions'
> usag...
1999 Jan 17
1
Other core dumps, with apologies
...re dumped if it was used
> as
>
> tapply(x,listOfFactors,vectorReturningFunction)
>
> My naive solution was :
>
> j <- tapply(x, listOfFactors) # get the product factor
> answer <- tapply(x,j,vectorReturningFunction)
> .... CODE TO GET THE LABELS RIGHT ....
> ansmat <- array(unlist(answer), dim=someStuff,
> dimnames=otherStuff))
>
>
> The 'flexibility' of being passed back different structures
> (list, vector, matrix) depending upon the input structures
> somewhat complicates the explanation of the functions'
> usag...