similar to: bug in apply with median

Displaying 20 results from an estimated 20000 matches similar to: "bug in apply with median"

2017 May 31
4
stats::line() does not produce correct Tukey line when n mod 6 is 2 or 3
Seriously, if a method gives a wrong result, it's wrong. line() does NOT implement the algorithm of Tukey, even not after the patch. We're not discussing Excel here, are we? The method of Tukey is rather clear, and it is NOT using the default quantile definition from the quantile function. Actually, it doesn't even use quantiles to define the groups. It just says that the groups
2002 Mar 30
2
Inconsistency among mean, median, max, var
I found a strange inconsistency: If m is a matrix and d is a data frame then - mean(m), median(m), max(m) and max(d) all return a single value but - mean(d) returns the column means - median(d) fails - both var(m) and var(d) return the variance covariance matrix You pretty much have to experiment to figure this out since much of this behavior is not readily obvious from the help files.
2011 Apr 27
3
median and data frames
Here are some data frames: df3.2 <- data.frame(1:3, 7:9) df4.2 <- data.frame(1:4, 7:10) df3.3 <- data.frame(1:3, 7:9, 10:12) df4.3 <- data.frame(1:4, 7:10, 10:13) df3.4 <- data.frame(1:3, 7:9, 10:12, 15:17) df4.4 <- data.frame(1:4, 7:10, 10:13, 15:18) Now here are some commands and their answers: > median(df3.2) [1] 2 8 > median(df4.2) [1] 2.5 8.5 > median(df3.3)
2009 Dec 23
2
Mean, median and other moments
Hi! Suppose I have a dataset as follows pd = c(10,7,10,11,7,11,7,6,8,3,12,7,7,10,10) I wish to calculate the mean, standard deviation, median, skewness and kurtosis i.e. regular standard statistical measures. average = mean(pd) stdev    = sd(pd) median = median(pd) skew    = skewness(pd) kurt     =  kurtosis(pd) Q. No (1) How do I get these at a stretch using some R package? I came across
2013 Feb 27
1
lattice xyplot point labelling
This is my reproducible example tv.ms<-structure(list(inq = structure(4:17, .Label = c("D4", "D5", "D6a", "D6b", "D6c", "D7", "D8", "F4", "F5a", "F5b", "F6a", "F6b", "F6c", "F6d", "F7a", "F7b", "F8"), class =
2017 May 29
3
stats::line() does not produce correct Tukey line when n mod 6 is 2 or 3
Here is an attached patch. Best, Serguei. Le 29/05/2017 ? 12:21, Serguei Sokol a ?crit : > The problem or actual R implementation relies on an assumption > that median(x[i] | x[i] <= quantile(x, 1/3)) == quantile(x, 1/6) > which reveals not to be true despite very trustful appearance. > > If we continue with the example of x=y=1:9 > then quantile(x, 1/6)=2.5 (here quantile()
1999 Nov 11
2
dimname'less array breaks apply (PR#318)
<<insert bug report here>> > apply(array(1:20,c(2,2,5)),2:3,function(x) x) Error: length of dimnames must match that of dims > Changing: dimnames = if (is.null(dn.ans)) list(ans.names, NULL) else c(list(ans.names), dn.ans) To: dimnames = if (length(dn)==0) NULL else if (is.null(dn.ans)) list(ans.names, NULL) else c(list(ans.names), dn.ans) seems to fix this. Chuck
2013 Dec 16
1
External pointers and changing SEXPTYPE
Dear Developers, I've been struggling through writing R extension in C. I've been using an external pointer to store my data (please see sample below). I encountered a very weird erroneous behaviour: when I tried to use my external pointer to a structure holding several types of data, including SEXPs, I discovered that SEXPs change their types between returning from initialization
2012 Sep 03
1
Possible page inefficiency in do_matrix in array.c
In do_matrix in src/array.c there is a type switch containing : case LGLSXP : for (i = 0; i < nr; i++) for (j = 0; j < nc; j++) LOGICAL(ans)[i + j * NR] = NA_LOGICAL; That seems page inefficient, iiuc. Think it should be : case LGLSXP : for (j = 0; j < nc; j++) for (i = 0; i < nr; i++) LOGICAL(ans)[i + j * NR] = NA_LOGICAL; or more simply : case
2005 Jun 08
2
get level combinations from "by" list
Dear useRs, Given this code I end up with a list of class "by": a <- sample(1:5,200,replace=TRUE) b <- sample(c("v1","v2","v3"),200,replace=TRUE) c <- sample(c(11,22,33),200,replace=TRUE) data <- runif(200) grouped <- by(data,list(a,b,c),function(x) {c(min=min(x),max=max(x), median=round(median(x),digits=2),mean=round(mean(x),digits=2))})
2017 May 31
2
stats::line() does not produce correct Tukey line when n mod 6 is 2 or 3
OTOH, > sapply(1:9, function(i){ + sum(dfr$time <= quantile(dfr$time, 1./3., type = i)) + }) [1] 8 8 6 6 6 6 8 6 6 Only the default (type = 7) and the first two types give the result lines() gives now. I think there is plenty of reasons to give why any of the other 6 types might be better suited in Tukey's method. So to my mind, chaning the definition of line() to give sensible
2006 Apr 10
2
Suggestions to speed up median() and has.na()
Hi, I've got two suggestions how to speed up median() about 50%. For all iterative methods calling median() in the loops this has a major impact. The second suggestion will apply to other methods too. This is what the functions look like today: > median function (x, na.rm = FALSE) { if (is.factor(x) || mode(x) != "numeric") stop("need numeric data")
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 <-
2011 Apr 26
7
Second largest element from each matrix row
Hi, I need to extract the second largest element from each row of a matrix. Below is my solution, but I think there should be a more efficient way to accomplish the same, or not? set.seed(1) a <- matrix(rnorm(9), 3 ,3) sec.large <- as.vector(apply(a, 1, order, decreasing=T)[2,]) ans <- sapply(1:length(sec.large), function(i) a[i, sec.large[i]]) ans Thanks in advance for your
1997 Jun 03
2
R-beta: patch 2
Perhaps I missed something obvious, but when I applied patch 2 and then recompiled R-0.49, I found that the objects such as glm.fit that were supposed to be updated still had their original definitions. After some hair-pulling, I remembered that patch saves a backup copy of the original files it changes. Because of the way the makefile for the system database is structured, both the new files and
2002 Oct 22
4
repeatedly crashing smbd when printing: broken pipe
for months, we keep fighting issues with smbd (now at released 2.2.6), config is with spoolss, domain logon, and the client in question is an NT4 machine. server is a i386/linux 2.2.19 For a very long time, we thought it was related to oplocks, but now after having them disabled, it still is there. Level 3 Log is as follows: [2002/10/22 17:08:18, 3] smbd/ipc.c:reply_trans(480) trans
2000 Jun 08
7
R Equivalent to matlab's find() command?
hi, Just a very simple question: is there an R equivalent to the matlab command find(X) which returns the indices of vector X that store non-zero elements? e.g. > find( [1 0 0 1 0]) ans = 1 4 so, in R, how do I do: ans <- rfind( c(1,0,0,1,0)) so that ans is the vector c(1,4) thanks, stephen -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help
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,
2000 Feb 07
4
Segmentation fault, devPS.c, 0.99.0 (PR#413)
Full_Name: Roger Bivand Version: 0.99.0 OS: RH Linux 6.1 Submission from: (NULL) (158.37.60.152) I am working on an interface between R and the GRASS geographical information system, written in R, with no dynamically loaded code. I have written full examples, and tested then under R 0.90.1, both by entering example() for each function and R CMD check, both of which worked without problem. Under
1999 Mar 24
2
Change of parsing parameters to functions between 0.63.1 and 0.63.3 ?
Hi, I wonder whether the mechanism of parsing parameters to functions has changed between 0.63.1 and 0.63.3? The following code yeils different results in R 0.63.1 (Version 0.63.1 (Dec 5, 1998)) and R 0.63.3. cave<-function(x,a,b) { return(c(mean(x[a],na.rm=T),mean(x[b],na.rm=T))) } datx <- data.frame(rbind(c(1,2,3,4),c(4,5,6,7)))