similar to: Sorting a matrix?

Displaying 20 results from an estimated 60000 matches similar to: "Sorting a matrix?"

2018 Apr 06
2
Part of fastpass in 'sort.list' can make sorting unstable
In the code of functions 'order' and 'sort.list' in R 3.5.0 alpha (in https://svn.r-project.org/R/branches/R-3-5-branch/src/library/base/R/sort.R), in "fastpass, take advantage of ALTREP metadata", there is "try the reverse since that's easy too...". If it succeeds, ties are reordered, violating stability of sorting. Example: x <- sort(c(1, 1, 3)) x # 1
2012 Apr 09
2
Help with Book example of Matrix application
I found this example in an Introductory R book in the chapter on Matrices and Arrays The array is > m [,1] [,2] [,3] [,4] [,5] [1,] 0 12 13 8 20 [2,] 12 0 15 28 88 [3,] 13 15 0 6 9 [4,] 8 28 6 0 33 [5,] 20 88 9 33 0 The code is #returns the minimum value of d[i,j], i !=j and the row attaining #the minimum, for square
2008 Apr 21
3
means and variances of several groups in the matrix
Dear R users, I have 32 observations in data x. After sorting this, I want to compute means and variances of 3 groups divided by "nr". Actually, the number of groups is flexible. Any suggestion will be greatly appreciated. Kathryn Lord --------------------------------------------------------------------------- x=rnorm(32) y=sort(x) nr=matrix(c(12,11,10,10,10,11),2,3) > nr
2011 Feb 03
2
Sorting a Data Frame by hybrid string / number key
Hi, I'm trying to present a table of some experimental data, and I want to order the rows by the instance names. The issue I've got is that there are a variety of conventions for the instance names (e.g. competition01, competition13, small_1, big_20, med_9). What I want to be able to sort them first in category order so: competition < small < med < big, and then perform the
1997 Sep 03
1
R-alpha: speed of sort(.) and order(.)
sort() and order() are not quite the same, as "one knows": o order allows breaking ties by more than one argument; o sort allows a 'partial' and 'na.last' argument Still, the following timing (on a `simple' UltraSparc I) suggest that actually two different algorithms are used > N <- 10000 > typeof(x0 <- 1:N) # --- x0 : already sorted --- [1]
2019 Dec 12
2
Inconsistencies in wilcox.test
>>>>> Karolis Koncevi?ius >>>>> on Mon, 9 Dec 2019 23:43:36 +0200 writes: > So I tried adding Infinity support for all cases. > And it is (as could be expected) more complicated than I thought. "Of course !" Thank you, Karolis, in any case! > It is easy to add Inf support for the test. The problems start with conf.int=TRUE.
2012 Aug 01
4
how to calculate seasonal mean for temperatures
Hello everybody, I need to calculate seasonal means with temperature data for my work. I have 70 files coming from weather stations, which looks like this for example: startdate <- as.POSIXct("01/01/2006", format = "%d/%m/%Y") enddate <- as.POSIXct("05/01/2006", format = "%d/%m/%Y") date <- seq(from = startdate, to = enddate, by =
2020 Sep 07
2
OrcV1 removal
Hi Andres, Postgres uses removable code support and Orcv1. I does make me quite > worried to see a phase where there'll be no viable way of using both in > llvm. Why isn't the right answer here to at lest develop the > replacement as a set of patches / as a branch that then can be merged as > a whole / shortly after each other, rather than just starting to develop > a
2007 Nov 05
1
order a matrix
Dear list, order(x,y,z) returns a permutation to order x, ties broken by y, remaining ties broken by z. (And so on.) What I'd like to do is order(X), where X is a matrix (or a list or data frame if necessary) of unspecified size, which orders X[,1], ties broken by X[,2], remaining ties broken by X[,3] and so on - without having to know and to write down how many columns X has. Any
2011 Mar 14
3
ideas on sorting
Hi, I have a character vector as below: a<-c('10','3R','4','4R','5','5R','6','6R','7','8','9','7R','1','10R','11'
2004 May 20
2
column sorting a matrix with indices returned
Hi, I'm trying to translate some Matlab code to R and I'm trying to implement the behavior of Matlab's sort() which when applied to a matrix will sort the columns returning the column sorted matrix as well as a matrix of permuted indices. Doing: > x <- matrix(c(3,4,2,6,3,4,8,7,5), nr=3) > x [,1] [,2] [,3] [1,] 3 6 8 [2,] 4 3 7 [3,] 2 4 5
2011 Mar 25
1
Matching package - Match function
Hi. I am using the Matching package for propensity score matching. For each treated unit, I want to find all control units whose propensity scores lie within a certain distance from the treated unit. The sample code is as follows: > library(Matching) > x <- rnorm(100000) > y <- rnorm(100000) > z <- rbinom(100000,1,0.002) > logit.reg <-
2006 Jun 21
5
rank(x,y)?
Suppose I have two columns, x,y. I can use order(x,y) to calculate a permutation that puts them into increasing order of x, with ties broken by y. I'd like instead to calculate the rank of each pair under the same ordering, but the rank() function doesn't take multiple values as input. Is there a simple way to get what I want? E.g. > x <- c(1,2,3,4,1,2,3,4) > y <-
2011 Aug 16
1
how to sort the levels of a table
Dear colleagues, I have really heavy problems in sorting the results of a table according to certain features of the levels in the table. Prerequisites: It all starts with a fairly simple data set, which stores observations of 21 observers (horizontally from 1 to 21; 21 is reference/goldstandard) who diagnosed 42 videos (vertically from 1 to 42). See dump of R-object "input" below in
2008 Dec 04
1
comparing SAS and R survival analysis with time-dependent covariates
Dear R-help, I was comparing SAS (I do not know what version it is) and R (version 2.6.0 (2007-10-03) on Linux) survival analyses with time-dependent covariates. The results differed significantly so I tried to understand on a short example where I went wrong. The following example shows that even when argument 'method' in R function coxph and argument 'ties' in SAS procedure
2019 Dec 07
2
Inconsistencies in wilcox.test
Thank you for a fast response. Nice to see this mailing list being so alive. Regarding Inf issue: I agree with your assessment that Inf should not be removed. The code gave me an impression that Inf values were intentionally removed (since is.finite() was used everywhere, except for paired case). I will try to adjust my patch according to your feedback. One more thing: it seems like you
2019 Dec 07
5
Inconsistencies in wilcox.test
Hello, Writing to share some things I've found about wilcox.test() that seem a a bit inconsistent. 1. Inf values are not removed if paired=TRUE # returns different results (Inf is removed): wilcox.test(c(1,2,3,4), c(0,9,8,7)) wilcox.test(c(1,2,3,4), c(0,9,8,Inf)) # returns the same result (Inf is left as value with highest rank): wilcox.test(c(1,2,3,4), c(0,9,8,7), paired=TRUE)
2007 Nov 06
2
Kolmogorov-Smirnoff test
I am trying to determine whether two samples are identical or not. I'm aware that somebody can use the Kolmogorov-Smirnoff test to compare empirical distributions, but since my samples have ties I'm not sure if I'm getting the right p-values for the comparison. Can the Kolmogorov-Smirnoff test be adjusted for the case when ties exists and are there any functions that already
2009 Mar 13
4
Sorting rows of a matrix independent of each other
Oh, this seemed so simple (and I'm sure the answer will be, as usual, so thanks in advance for enlightening me). I need to sort each row of a matrix independent of the others. For example, > test <- matrix(c(8,7,1,2,6,5,9,4,3),nrow=3) > test [,1] [,2] [,3] [1,] 8 2 9 [2,] 7 6 4 [3,] 1 5 3 I can get each row sorted well enough. > sort(test[1,]) [1]
2009 May 27
3
Defining functions - an interesting problem
I define the following function: (Please don't wonder about the use of this function, this is just a simplified version of my actual function. And please don't spend your time in finding an alternate way of doing the same as the following does not exactly represent my function. I am only interested in a good explanation) > f1 =