similar to: A problem with order() function in R

Displaying 20 results from an estimated 5000 matches similar to: "A problem with order() function in R"

2006 Jun 18
2
Books
Dears, I saw in the R-project site some R-books. However, I'm new in this community and I didn't figure out what are the best books. Can you suggest me some "reference" books? My intentions with R is concerned to Artificial Intelligence simulations, Classification and general Statistics (e.g., regression, multivariate regression, etc). Thanks for any help, Anderson
2009 Apr 22
5
large factorials
I am working on a project that requires me to do very large factorial evaluations. On R the built in factorial function and the one I created both are not able to do factorials over 170. The first gives an error and mine return Inf. Is there a way to have R do these larger calculations (the calculator in accessories can do 10000 factorial and Maple can do even larger) -- View this message in
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
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:
2009 Jun 04
4
order() with randomised order in ties?
Hi I want to use order() to get the order of a vector. But I would need a different behavior when ties occur: similar to the parameter ties.method = "random" in the rank() function, I would need to randomise the ties. Is this possible? Example: x <- rep(1:10, 2) order(x) [1] 1 11 2 12 3 13 4 14 5 15 6 16 7 17 8 18 9 19 10 20 order(x) [1] 1 11 2 12 3 13 4 14 5 15
2002 May 06
3
Spearman rank-order correlation matrix
I"ve got a data frame with a selection of columns I want to compute a rank-order correlation matrix from without disturbing the original data frame. foo[,c("a","b","d","f","g")] What I wanted to do, intuitively, was: > cor(rank(foo[,c("a","b","d","f","g")])) but rank in that context
2007 Mar 19
5
order of values in vector
Dear all, I would like to get the order of the values in a vector. I have tried rank(), order() and searched the archive, though without success. Here is an example of a try x= c(20,30,50,40,60,10) cbind(sort.list(x),x) x [1,] 6 20 [2,] 1 30 [3,] 2 50 [4,] 4 40 [5,] 3 60 [6,] 5 10 but I was hoping to get this: x [1,] 2 20 [2,] 3 30 [3,] 5 50 [4,] 4 40 [5,] 6 60 [6,] 1 10 I'm
2006 Jan 26
4
Override has_many :order at run-time?
Is it possible to override has_many''s :order attribute at run-time? e.g. something like: <% for category in @site.categories(:order=>''name'') %> ... <% for category in @site.categories(:order=>''rank'') %> ... thanks csn -- Posted via http://www.ruby-forum.com/.
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)
2011 Dec 07
4
bug in rank(), order(), is.unsorted() on character vector
Hi, This looks OK: > x <- c("_1_", "1_9", "2_9") > rank(x) [1] 1 2 3 But this does not: > xa <- paste(x, "a", sep="") > xa [1] "_1_a" "1_9a" "2_9a" > rank(xa) [1] 2 1 3 Cheers, H. > sessionInfo() R version 2.14.0 (2011-10-31) Platform: x86_64-unknown-linux-gnu (64-bit) locale: [1]
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
2001 Nov 24
4
about the function order()
Dear all, I have recently experienced something with the function order I cannot explain: The help(order) (which I admit having overlooked before) rises even more my confusion... The following lines made me think order() was returning the 'order' each value in a vector would take when sorted. > a <- c(4.1, 3.2, 6.1) > order(a) [1] 2 1 3 Doing > plot(a,
2008 Feb 28
4
p-value in Spearman rank order
Dear R-helpers, I would like to do a Spearman rank order test, and used the cor() function with the method "spearman". It gives me a number (correlation coefficient?) , but how can I get the p-value? Thank you for the help in advance! Regards, Anne-Katrin -- [[alternative HTML version deleted]]
2002 Jan 24
3
getting rank order
I'm doing a study where people place a deck of cards in a certain order. It's sufficient to assume that their colors & each has a number (it's actually about attributes of hobbies). I'd like to look for patterns in how they've arranged the deck. For each subject I have a list like 3,5,2,4,1, indicating that (s)he chose 3 first, then 5, then 2. . . . I think what I first
2012 Jan 27
2
Why does the order of terms in a formula translate into different models/ model matrices?
Dear all, I have encountered some strange things when creating lm objects in R: model depends on the order of the terms specified in a formula. Let us consider the following simple example: > dat <- expand.grid(A = factor(c("a1", "a2")), + B = factor(paste("b", 1:4, sep="")), + rep = factor(1:2)) >
2013 Apr 16
6
I don't understand the 'order' function
I thought I've understood the 'order' function, using simple examples like: order(c(5,4,-2)) [1] 3 2 1 However, I arrived to the following example: order(c(2465, 2255, 2085, 1545, 1335, 1210, 920, 210, 210, 505, 1045)) [1] 8 9 10 7 11 6 5 4 3 2 1 and I was completely perplexed! Shouldn't the output vector be 11 10 9 8 7 6 4 1 2 3 5 ? Do I have a damaged
2002 Mar 29
2
order()
Hi, In the order() help file, there is an example like: a <- c(4, 3, 2, NA, 1) b <- c(4, NA, 2, 7, 1) z <- cbind(a, b) (o <- order(a, b)); z[o, ] How can I do something like "order a in ascending order, b in descending order"? And say I have a third vector c, and I'd like to add this to the previous condition "a ascending, b descending, c
2014 Sep 08
2
Problem with order() and I()
I have found that order() fails in a rather arcane circumstance, as in this example: > foo <- I( c('x','\265g') ) > order(foo) Error in if (xi > xj) 1L else -1L : missing value where TRUE/FALSE needed > foo <-c('x','\265g') > order(foo) [1] 1 2 > sessionInfo() R version 3.1.1 (2014-07-10) Platform: x86_64-apple-darwin13.1.0 (64-bit)
2010 Jul 21
1
lm: order of dropped columns
Hi all, If presented with a singular design matrix, lm drops columns to make the design matrix non-singular. What algorithm is used to select which (and how many) column(s) to drop? Particularly, given a factor, how does lm choose levels of the factor to discard? Thanks for the help. Best, Anirban [[alternative HTML version deleted]]
2008 Oct 29
3
Incorrect order
I am using the order function and the result seems to be incorrect: > a<-c(20,30,15,40) > order(a) [1] 3 1 2 4 Any suggestions? Thanks, Laura -- View this message in context: http://www.nabble.com/Incorrect-order-tp20224993p20224993.html Sent from the R help mailing list archive at Nabble.com.