Displaying 20 results from an estimated 40000 matches similar to: "Function rank() for data frames (or multiple vectors)?"
2017 Aug 24
1
[patch] Fix typo in 'rank' documentation
I noticed a typo in the documentation for the 'rank' function.
Specifically, it describes ties.method="first" and contrasts with...
ties.method="first", when it should be ties.method="last".
Thanks,
Jon
-------------- next part --------------
Index: src/library/base/man/rank.Rd
===================================================================
---
2015 Oct 08
3
rank(, ties.method="last")
Hi,
I ran into a problem where I actually need rank(, ties.method="last"). It would
be great to have this feature in base and it's also simple to get (see below).
Thanks & cheers,
Marius
rank2 <- function (x, na.last = TRUE, ties.method = c("average",
"first", "last", # new "last"
"random", "max",
2006 Oct 27
1
What to do with a inconsistency in rank() that's in S+ and R ever since?
Dear R-developers,
I just realized that rank() behaves inconsistent if combining one of na.last in {TRUE|FALSE} with a ties.method in {"average"|"random"|"max"|"min"}.
The documentation suggests that e.g. with na.last=TRUE NAs are treated like the last (=highest) value, which obviously is not the case:
> rank(c(1,2,2,NA,NA), na.last = TRUE, ties.method
2004 Mar 30
4
rank() vs SAS proc rank
SAS proc rank has ties options of high and low that would allow
producing ranks of the type found in the sports pages, e.g.,
rank (c(1,1,2,2,2,2,3)) == 1 1 3 3 3 3 7
Could R support these ties.methods?
2012 Nov 21
1
I don't know the difference between rank and order
I don't know the difference between rank and order.For example:
> x=c(10,30,30,20,10,20)
> x[rank(x,ties.method="first")]
[1] 10 10 20 30 30 20
> x[order(x)]
[1] 10 10 20 20 30 30
the result is quite different,
x[rank(x,ties.method="first")]
[1] 10 10 20 30 30 20
It is not sorted,why?
--
View this message in context:
2007 Jan 11
1
rank function and NA in 2.3.1
Hi.
I am using R 2.3.1 on WIndows XP, and I am having trouble with the rank
function in the presence of numerical NA data. I want the NA's all to get
the same rank, but they don't. Here is an example from my session:
>ct_align_rets_f2$liq[6851:6859]
[1] 115396 NA 362595 NA 242986 340805 NA 692905 251533
2004 Mar 15
1
spearman rank correlation problem
Hello R gurus,
I want to calculate the Spearman rho between two ranked lists. I am
getting results with cor.test that differ in comparison to my own
spearman function:
> my.spearman
function(l1, l2) {
if(length(l1) != length(l2)) stop("lists must have same length")
r1 <- rank(l1)
r2 <- rank(l2)
dsq <- sapply(r1-r2,function(x) x^2)
1 - ((6 * sum(dsq))
2003 Jul 22
1
rank with ties
Hi,
Is there a function like rank but that solves the ties by randomly assigning
a value (doesn't average ranks of ties).
This is what I actually need:
I want to make NA all elements of each column in an array that are ranked in
a position larger that rankmax for each column.
# Say I've got an array b:
b<-cbind(c(1:5,5:1),c(1,12,14,2,5,4:8))
#> b
# [,1] [,2]
#[1,] 1 1
2006 Aug 25
1
exact Wilcoxon signed rank test with ties and the "no longer under development" exactRanksumTests package
Dear List,
after updating the exactRanksumTests package I receive a warning that
the package is not developed any further and that one should consider
the coin package.
I don't find the signed rank test in the coin package, only the Wilcoxon
Mann Whitney U-Test. I only found a signed rank test in the stats
package (wilcox.test) which is able to calculate the exact pvalues but
unfortunately
2004 Apr 20
2
Rank - Descending order
Dear All,
Is there any simple way to way to produce "rank", for a given
list, but in a descending order?
E.G:
x = list(a=c(1,5,2,4));
rank(x$a); produces 1,4,2,3
However I am looking for a way to generate (4,1,3,2).
It would be particularly nice if the proposed solution has all
the niceties of rank function (like NA handling and ties.method
functionality)
TIA
Manoj
2007 Aug 17
2
problem using "rank"
Hi All,
I had 12766 elements in a column, 12566 are values and 200 are "NA"s. I used the following line to get the ranks:
total_list$MB.rank <- rank(-total_list$MB,ties.method="min",na.last=NA)
but I got an error message:
Error in `$<-.data.frame`(`*tmp*`, "BCRP_PW_F.rank", value = c(3949, 6182, :
replacement has 12199 rows, data has 12766
What
2007 Aug 06
1
rank in decreasing order
Hi All,
I want to give ranks to elements in a column so I used:
total_list$field1.rank <- rank(total_list$field1,ties.method="min")
But this gives me the rank in increasing order. How do I get the ranks in decreasing order? I know decreasing = FALSE is not a legal argument here.
Thanks.
Jiong
The email message (and any attachments) is for the sole use of the intended recipient(s)
2010 Jan 08
2
A better way to Rank Data that considers "ties"
This will start off sounding very easy, but I think it will be very
complicated.
Let's say that I have a matrix, which shows the number of apples that each
person in a group has.
OriginalMatrix<-matrix(c(2,3,5,4,6),nrow=5,ncol=1,byrow=T,dimnames=list(c("Bob","Frank","Joe","Jim","David"),c("Apples")))
Apples
Bob 2
2011 Apr 12
2
The three routines in R that calculate the wilcoxon signed-rank test give different p-values.......which is correct?
I have a question concerning the Wilcoxon signed-rank test, and
specifically, which R subroutine I should use for my particular dataset.
There are three different commands in R (that I'm aware of) that calculate
the Wilcoxon signed-rank test; wilcox.test, wilcox.exact, and
wilcoxsign_test. When I run the three commands on the same dataset, I get
different p-values. I'm hoping that
2004 Jun 25
3
alternate rank method
Hi,
I'm wondering if anyone can point me to a function that will
allow me to do a ranking that treats ties differently than
rank() provides for?
I'd like a method that will assign to the elements of each
tie group the largest rank.
An example:
For the vector 'v', I'd like the method to return 'rv'
v: 1 2 3 3 3 4 5 5 6 7
rv: 1 2 5 5 5 6 8 8 9 10
Thanks,
2011 Apr 13
2
Wilcoxon rank sum in unbalanced design
Hi everyone!
I need to perform a Wilcoxon rank sum test, but I have some ties and the
groups have different size also. When I deal with ties I use the
wilcox.exact function, how can I solve the different size problem using this
function?
thanks
net
--
View this message in context: http://r.789695.n4.nabble.com/Wilcoxon-rank-sum-in-unbalanced-design-tp3447400p3447400.html
Sent from the R help
2001 Nov 28
2
Problems with rank()
If you enter the following values for x and y:
x: 2.2 3.7 2.1 0.4 2.8 0.3 0.4 1.4 5.4 6.0
y: 6.0 8.1 1.8 1.3 5.2 0.6 1.0 1.9 6.8 6.5
and do rank(abs(y-x)),
you should get two ties, one at 0.3 and one at 0.5.
R, and S-Plus5 by that matter recognise the tie at 0.5 and give
it rank 3.5, but gives one of the two 0.3 values rank 1 and one of
them 2, whereas they should boh be 1.5.
Any suggestions?
when
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 Nov 21
2
count ties after rank?
Hello!
I need to use Kruskal-Wallis test and post-hoc test (Dunn's test) for my data. But when I searched around, I only found this function: kruskal.test. But nothing for Dunn's test.
So I started to write one myself. But I do not know how to count ties in the data frame. I can use for loops but it seems long and unnecessary since the rank function actually knows the ties. So
2004 Dec 01
2
rank in descending order?
Hi,
Is there any simple solution to get ranks in descending order?
Example,
a <- c(10, 98, 98, 98, 99, 100)
r <- rank(a, ties.method="average")
produces
1 3 3 3 5 6
I would want this instead:
6 5 3 3 3 1
Note that reversing r doesn't work but in small examples.
Thanks,
-Jose
--
jquesada at andrew.cmu.edu Research associate
http://lsa.colorado.edu/~quesadaj Dept. of