similar to: by inconsistently strips class - with fix

Displaying 20 results from an estimated 1000 matches similar to: "by inconsistently strips class - with fix"

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
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)),
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
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)
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 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 >
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 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
2007 Dec 10
2
bug in by.data.frame, R-2.6.1 (PR#10506)
by() fails for 1-column matrices and dataframes: X <- data.frame(a=1:10) g <- gl(2,5) by(X, g, colMeans) Suggested fix: --- by-old.R 2007-12-10 15:26:22.501086600 +0100 +++ by.R 2007-12-10 15:25:58.390477200 +0100 @@ -26,7 +26,7 @@ IND[[1]] <- INDICES names(IND) <- deparse(substitute(INDICES))[1] } else IND <- INDICES - FUNx <-
2006 Dec 02
2
nonlinear quantile regression
Hello, I?m with a problem in using nonlinear quantile regression, the function nlrq. I want to do a quantile regression o nonlinear function in the form a*log(x)-b, the coefficients ?a? and ?b? is my objective. I try to use the command: funx <- function(x,a,b){ res <- a*log(x)-b res } Dat.nlrq <- nlrq(y ~ funx(x, a, b), data=Dat, tau=0.25, trace=TRUE) But a can?t solve de problem,
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
2010 Sep 13
2
value returned by by()
Hi, I noticed that by() returns an object of class 'by', regardless of what its argument 'simplify' is. ?by says that it always returns a list if simplify=FALSE, yet by.data.frame shows: ---<--------------------cut here---------------start------------------->--- function (data, INDICES, FUN, ..., simplify = TRUE) { if (!is.list(INDICES)) { IND <-
2008 Dec 16
2
Problem assigning "NA" as a level name in a list
I want to generate a list (called "dataList" below) where each of its levels is named. These names are assigned to nameList, which contains all possible permutations of size two taking letters from a larger alphabet, e.g., "aa",...,"Fd",..,"Z1",... One of these permutations is the character string "NA". It seems that when I try to name one
2005 Apr 16
2
String in data frame
hello, how can take the string in the data frame. right now i have a table that create as a data frame and stored in the file called "data.xls" and now i want to read data frame as a table in my another r program, i used the following command: the first column of the data frame is just one number called "num", but the second one a list of string, called "name". d
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).
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
2011 Apr 21
1
problem subsetting of a reference class
I am trying to define subset operator for a reference class and hitting some problem i am unable to diagnose.To give an example, here is a toy class generator that is a wrapper around a list tmpGEN<-setRefClass("TMP", fields=list( namelist="list" )) tmpGEN$methods('add'=function(obj, name){ namelist[[name]]<<-obj })
2012 Jan 26
2
Inserting a character into a character string XXXX
Hello everyone, I have a character vector of 24 hour time values in the format hm without the delimiting ":". How can I insert the ":" immediately to the left of the second digit from the right? mytimes<-scan(what="") 1457 1457 1310 1158 137 1855 Thanks! Dan