Re: [R] Sorting based a custom sorting function

2023-12-14 Thread Duncan Murdoch
ere the pairwise comparison is obvious, while the numeric conversion isn't. A simple one would be a list of string vectors of different lengths, where you want to sort lexicographically. Duncan Have fun with the remainder of the advent! Another Martin From: R-help on behalf of Martin Møller Skar

Re: [R] Sorting based a custom sorting function

2023-12-14 Thread Martin Morgan
h for S3 generics), but rather define a class (e.g., that requires vectors person and value) and implement a corresponding `xtfrm()` method. Have fun with the remainder of the advent! Another Martin From: R-help on behalf of Martin Møller Skarbiniks Pedersen Date: Thursday, December 14, 2023

Re: [R] Sorting based a custom sorting function

2023-12-14 Thread Martin Møller Skarbiniks Pedersen
On Thu, 14 Dec 2023 at 12:02, Duncan Murdoch wrote: > > class(df$value) <- "sizeclass" > > `>.sizeclass` <- function(left, right) custom_sort(unclass(left), > unclass(right)) == 1 > > `==.sizeclass` <- function(left, right) custom_sort(unclass(left), > unclass(right)) == 0 > > `[.sizeclass` <- fu

Re: [R] Sorting based a custom sorting function

2023-12-14 Thread Martin Møller Skarbiniks Pedersen
> This sounds suspiciously like homework (which is off-topic... see the Posting > Guide) It is not homework. Currently I am trying to solve this: https://adventofcode.com/2023/day/7 But it is something that has puzzled me for a long time. In many programming languages, you can give a "less" func

Re: [R] Sorting based a custom sorting function

2023-12-14 Thread Duncan Murdoch
On 14/12/2023 3:00 a.m., Martin Møller Skarbiniks Pedersen wrote: Hi, I need to sort a data.frame based on a custom sorting function. It is easy in many languages but I can't find a way to do it in R. In many cases I could just use an ordered factor but my data.frame contains poker han

Re: [R] Sorting based a custom sorting function

2023-12-14 Thread Jeff Newmiller via R-help
This sounds suspiciously like homework (which is off-topic... see the Posting Guide), and you haven't indicated how you plan to encode your poker hands, and most core features of other languages are possible in R so if you really understand these other techniques and R then you should be able to

Re: [R] Sorting boxplots

2022-03-14 Thread Erich Subscriptions
Make the grouping variable into a factor end define the level ordering. ?factor will tell you more. > On 14.03.2022, at 17:39, Ebert,Timothy Aaron wrote: > > Set the factor levels rather than using the R default. > > -Original Message- > From: R-help On Behalf Of Fernando Archuby > Sen

Re: [R] Sorting vector based on pairs of comparisons

2019-03-15 Thread Jim Lemon
Hi Bert, Good reference and David Urbina's example showed that a simple swap was position dependent. The reason I pursued this is that it seems more efficient to sequentially apply the precedence rules to the arbitrarily sorted elements of the vector than to go through the directed graph approach.

Re: [R] Sorting vector based on pairs of comparisons

2019-03-15 Thread Pedro Conte de Barros
Thanks Bert. Excellent reference, I learned a lot from it! Just a note: I did use search engines for at least 2 days before posting. BUT as often happens, I did not use the right keywords. I tried several variants of "Convert ordered pairs to sorted", "Sort vector on paired comparisons" and abo

Re: [R] Sorting vector based on pairs of comparisons

2019-03-15 Thread Bert Gunter
If I understand correctly, the answer is a topological sort. Here is an explanation https://davidurbina.blog/on-partial-order-total-order-and-the-topological-sort/ This was found by a simple web search on "Convert partial ordering to total ordering" Btw. Please use search engines before posting

Re: [R] Sorting vector based on pairs of comparisons

2019-03-14 Thread Jim Lemon
Hi Pedro, This looks too simple to me, but it seems to work: swap<-function(x,i1,i2) { tmp<-x[i1] x[i1]<-x[i2] x[i2]<-tmp return(x) } mpo<-function(x) { L<-unique(as.vector(x)) for(i in 1:nrow(x)) { i1<-which(L==x[i,1]) i2<-which(L==x[i,2]) if(i2 wrote: > > Dear All, > > This should be

Re: [R] Sorting vector based on pairs of comparisons

2019-03-14 Thread William Dunlap via R-help
This is called topological sorting in some circles. The function below will give you one ordering that is consistent with the contraints but not all possible orderings. I couldn't find such a function in core R so I wrote one a while back based on Kahn's algorithm, as described in Wikipedia. > S

Re: [R] Sorting vector based on pairs of comparisons

2019-03-14 Thread Pedro Conte de Barros
Thanks for this. Yes, this is checked before trying to process this. Pedro On 14/03/2019 14.09, Bert Gunter wrote: This cannot be done unless transitivity is guaranteed. Is it? S L a b b c c a Bert On Thu, Mar 14, 2019, 4:30 AM Pedro Conte de Barros mailto:pbar...@ualg.pt>> wrote: Dea

Re: [R] Sorting vector based on pairs of comparisons

2019-03-14 Thread Bert Gunter
This cannot be done unless transitivity is guaranteed. Is it? S L a b b c c a Bert On Thu, Mar 14, 2019, 4:30 AM Pedro Conte de Barros wrote: > Dear All, > > This should be a quite established algorithm, but I have been searching > for a couple days already without finding any satisfact

Re: [R] Sorting vector based on pairs of comparisons

2019-03-14 Thread Richard M. Heiberger
Try this. Anything that appears only in Smaller is candidate for smallest. Among those, order is arbitrary. Anything that appears only in Larger is a candidate for largest. Among those order is arbitrary. Remove rows of matComp containing the already classified items. Repeat with the smaller set

Re: [R] Sorting of character vectors

2016-11-08 Thread Pascal A. Niklaus
Thanks for all suggestions. With my build (from the CRAN repo) I don't get ICU support, and setting LC_COLLATE to "C" did not help. > capabilities("ICU") ICU FALSE > sessionInfo() R version 3.3.2 (2016-10-31) Platform: x86_64-pc-linux-gnu (64-bit) Running under: Ubuntu 14.04.5 LTS locale:

Re: [R] Sorting of character vectors

2016-11-08 Thread Rui Barradas
Hello, What is your sessionInfo()? With me it works as expected: > sort(c("-", "+")) [1] "-" "+" > sort(c("+", "-")) [1] "-" "+" > x5 <- c("+Aa","-Ab") > sort(x5) [1] "-Ab" "+Aa" > sessionInfo() R version 3.3.2 (2016-10-31) Platform: x86_64-w64-mingw32/x64 (64-bit) Running under: Windows 7 x64

Re: [R] Sorting of character vectors

2016-11-08 Thread peter dalgaard
On 08 Nov 2016, at 13:18 , Pascal A. Niklaus wrote: > I just got caught by the way in character vectors are sorted. > > It seems that on my machine "sort" (and related functions like "order") only > consider characters related to punctuation (at least here the "+" and "-") > when there is no

Re: [R] sorting of files using system

2016-04-09 Thread Adrian Dușa
I suspect it is a problem related to locales: R and the base Ubuntu might be using different locales, hence the source of the different sorting. Can't say if this is the problem in your case, but it might be. Adrian On Sat, Apr 9, 2016 at 12:18 AM, Maria Ninova wrote: > Hello, I came across the

Re: [R] sorting of files using system

2016-04-08 Thread Jeff Newmiller
Wrong list. This is not the Ubuntu shell support mailing list. The fact that you are using R to get at the operating system command line doesn't make this an R question. -- Sent from my phone. Please excuse my brevity. On April 8, 2016 2:18:40 PM PDT, Maria Ninova wrote: >Hello, I came acros

Re: [R] Sorting in trees problem

2016-02-24 Thread Bert Gunter
"%in%" is a wrapper for match(), which uses hashing I believe (correction welcome!),and so is generally very fast. See ?Rprof for profiling R code to get timings. (Haven't used it myself, so not sure how useful it would be for this situation). -- Bert Bert Gunter "The trouble with having an o

Re: [R] sorting matrix by sets rows

2016-02-06 Thread Bert Gunter
?order is what I think you want. There is a slight wrinkle here, however. You want to sort Cluster in *increasing* order and Byers_EMT in *decreasing*, as I understand. order() will do both increasing, or both decreasing, but not differently. So a simple but inefficient way around this is to first

Re: [R] Sorting a Data Frame

2016-01-26 Thread Bert Gunter
... > mydf[2] # ??? B 1 4 2 5 3 6 A data frame is "really" a list of columns, so giving a single value returns that column. False. It returns a data frame consisting of a single column = a list containing a single component. mydf[[2]] returns a single component/column. While these differ

Re: [R] Sorting a Data Frame

2016-01-26 Thread Sarah Goslee
On Tue, Jan 26, 2016 at 4:24 PM, Robert Sherry wrote: > > Thank you for the response. As expected, the following expression worked: > df[order(df$x),] This says to sort the rows, and leave the columns alone. Subsetting a 2-dimensional object is via [rows, columns] > I would expect the follo

Re: [R] Sorting a Data Frame

2016-01-26 Thread Robert Sherry
Thank you for the response. As expected, the following expression worked: df[order(df$x),] I would expect the following expression to work also: df[order(df$x)] However it does not. That is, the comma is needed. Please tell me why the comma is there. Thanks Bob On 1/26/2016 8:19 A

Re: [R] Sorting a Data Frame

2016-01-26 Thread S Ellison
> On 23.01.2016 01:21, Robert Sherry wrote: > > In R, I run the following commands: > > df = data.frame( x=runif(10), y=runif(10) ) > > df2 = df[order(x),] > > > You use another x from your workspace, you actually want to > > > df2 = df[order(df[,"x"]),] or df[order(df$x),] And

Re: [R] Sorting a Data Frame

2016-01-22 Thread Uwe Ligges
On 23.01.2016 01:21, Robert Sherry wrote: In R, I run the following commands: df = data.frame( x=runif(10), y=runif(10) ) df2 = df[order(x),] You use another x from your workspace, you actually want to df2 = df[order(df[,"x"]),] Best, Uwe Ligges The first, as I would expect

Re: [R] sorting a dataframe

2015-06-21 Thread Bogdan Tanasa
Thank you all again. It works with : library("gtools") dat[mixedorder(A),] considering : A = c("A1","A10","A11","A2") B = c(1,2,3,4) dat = data.frame(A,B On Sun, Jun 21, 2015 at 10:52 AM, Bert Gunter wrote: > Diego: > > Nonsense! Look at the results of your code -- you have failed to order

Re: [R] sorting a dataframe

2015-06-21 Thread Bert Gunter
Diego: Nonsense! Look at the results of your code -- you have failed to order the results as had been requested by the OP. It's also unnecessarily complicated. The following suffices (where I have used regular expressions rather substring() to get the numeric part of the strings -- **assuming** th

Re: [R] sorting a dataframe

2015-06-21 Thread Diego Miro
Bogdan, Follow my suggestion. letter <- substring(A, 1, 1) number <- substring(A, 2, nchar(A)) new.data <- paste0(letter, formatC(as.numeric(number), width = 2, flag = "0")) Em 20/06/2015 21:21, "Bogdan Tanasa" escreveu: > Dear all, > > I am looking for a suggestion please regarding sorting a d

Re: [R] sorting a dataframe

2015-06-20 Thread Bogdan Tanasa
thank you all, it is working fine. happy weekend ;) ! On Sat, Jun 20, 2015 at 6:15 PM, David Winsemius wrote: > > On Jun 20, 2015, at 5:18 PM, Bogdan Tanasa wrote: > > > Dear all, > > > > I am looking for a suggestion please regarding sorting a dataframe with > > alphanumerical components : > >

Re: [R] sorting a dataframe

2015-06-20 Thread David Winsemius
On Jun 20, 2015, at 5:18 PM, Bogdan Tanasa wrote: > Dear all, > > I am looking for a suggestion please regarding sorting a dataframe with > alphanumerical components : > > let's assume we have : > > A = c("A1","A10","A11","A2") > B = c(1,2,3,4) > > C = data.frame(A,B) > > how could I sort C

Re: [R] sorting means for plot in descending order (Luis Fernando Garc?a)

2015-04-09 Thread Manel Amado Martí
Re: Try with sort() function sort(x, decreasing = FALSE, ...) As you can see, u can set the argument decreasing=TRUE, then, it'll sort by decreasing order. For more details, call: help(sort) under R console Message: 23 Date: Thu, 9 Apr 2015 03:11:37 -0300 From: Luis Fernando Garc?a To: r-hel

Re: [R] sorting means for plot in descending order

2015-04-09 Thread peter dalgaard
> On 09 Apr 2015, at 08:11 , Luis Fernando García wrote: > > Dear R experts, > > I am newbie on the R use, now I want to sort my data by mean in a > descending and not acending order (like I have done so far). If any of you > could help me with this, it would be really appreciated! How about

Re: [R] Sorting list elements according to their mean value

2015-03-03 Thread William Dunlap
Use order(), as in sortListByMean <- function(List) { List[order(vapply(List, mean, 0))] } sortedL <- sortListByMean(l) Bill Dunlap TIBCO Software wdunlap tibco.com On Tue, Mar 3, 2015 at 11:01 AM, wrote: > Hello R-helpers, > > I have a list of 999 dataframes and I would like to s

Re: [R] Sorting data frame by prepared order

2015-03-02 Thread JS Huang
Here is an implementation. > t <- > data.frame(x=c(1,1,1,1,1,2,2,2,2,2),y=c("a","a","a","b","b","a","a","b","b","b")) > t x y 1 1 a 2 1 a 3 1 a 4 1 b 5 1 b 6 2 a 7 2 a 8 2 b 9 2 b 10 2 b > assignSeq function(test) { temp <- test[order(test$x),] InC <- numeric(length(test)) inD <-

Re: [R] Sorting data frame by prepared order

2015-03-02 Thread jeff6868
Hi, Maybe a beginning of solution with this? test <- data.frame(x=c(1,1,1,1,1,1,2,2,2,2,2,2),y=c("a","a","a","b","b","b","a","a","b","b","b","a")) test[order(test$x),] out <- split(test,test$x) for (i in 1:length(out)) { foo <- unique(out[[i]][,2]) out[[i]][,2] <- rep(foo,(nrow(out[[

Re: [R] Sorting Surv objects

2015-02-14 Thread Professor Bickis
Thanks for the quick response. My work-around was suggested as a quick fix for right-censored data, not as a general sort method for censored data. My concern was that sort does not work on right-censored data as described in the xtfrm documentation. Mik Bickis > On Feb 13, 2015, at 05:53 A

Re: [R] Sorting Surv objects

2015-02-13 Thread Therneau, Terry M., Ph.D.
Your work around is not as "easy" looking to me. Survival times come in multiple flavors: left censored, right censored, interval censored, left-truncated and right censored, and multi-state. Can you give me guidance on how each of these should sort? If a sort method is added to the package i

Re: [R] Sorting Surv objects

2015-02-12 Thread Prof Brian Ripley
On 12/02/2015 16:26, Professor Bickis wrote: It seems that Surv objects do not sort correctly. This seems to be a bug. Anyone else found this? This is presumably about Surv() from package survival, not mentioned. There was a bug, corrected in R-devel (and I will port to R-patched before 3.

Re: [R] Sorting method used by order()

2014-12-02 Thread Prof Brian Ripley
On 02/12/2014 12:28, Pierrick Bruneau wrote: I'll try to be more specific: - ?order points to a common man page for both order() and sort.list() - sort.list() has a "method" argument, i.e. a sorting algorithm. As far as I can read, I'll rather say the default is "shell" Not quite: the page says

Re: [R] Sorting method used by order()

2014-12-02 Thread Duncan Murdoch
On 02/12/2014, 7:28 AM, Pierrick Bruneau wrote: > I'll try to be more specific: > - ?order points to a common man page for both order() and sort.list() > - sort.list() has a "method" argument, i.e. a sorting algorithm. As far as > I can read, I'll rather say the default is "shell" > - order() seems

Re: [R] Sorting method used by order()

2014-12-02 Thread Pierrick Bruneau
I'll try to be more specific: - ?order points to a common man page for both order() and sort.list() - sort.list() has a "method" argument, i.e. a sorting algorithm. As far as I can read, I'll rather say the default is "shell" - order() seems not to support this argument. My questions were thus 1) w

Re: [R] Sorting method used by order()

2014-12-02 Thread PIKAL Petr
Hi Can you be more specific? How do you want parametrize order? There is no sort.list argument in order. For sort list, the default method is "radix", AFAIK. Cheers Petr > -Original Message- > From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of > Pierrick Bruneau > Sent: Tu

Re: [R] Sorting within a dataframe Thank you

2014-10-31 Thread dodie
Thank you. Original Message Subject: Re: Sorting within a dataframe From: "jfzeac [via R]" < ml-node+s789695n4699000...@n4.nabble.com > Date: Thu, October 30, 2014 8:57 am To: dodie < do...@statcourse.com > Hi, a = data[order(data$x),] If you reply to this email, yo

Re: [R] Sorting data.frame datewise in a descending order and geting datewise subtotl

2014-07-03 Thread arun
Hi, Try: res1 <- aggregate(PROFIT~DATE, data=dat, FUN=sum) res1[rev(order(as.Date(res1$DATE, format="%d/%m/%Y"))),] #    DATE PROFIT #2 02/07/2014  -1350 #1 01/07/2014   9400 #4 30/06/2014  11325 #3 27/06/2014   6850 #if you don't wanted another column in the original dataset with `sum`  re

Re: [R] Sorting data.frame datewise in a descending order and geting datewise subtotl

2014-07-03 Thread veepsirtt
Hi A.K I modified and got the results thanks A.K library(XML) URL <- " http://money.securebank.in/index.php?option=com_dashboard&view=history&Itemid=56&startdate=01/01/2014&enddate=02/07/2014&exchange=MCX&sid=1 " doc <- htmlParse(URL) tableNodes <- getNodeSet(doc, "//table") l=length(tableNodes)

Re: [R] Sorting data.frame datewise in a descending order and geting datewise subtotl

2014-07-03 Thread veepsirtt
Warning in install.packages : package ‘dplyr’ is not available (for R version 2.15.3) Is there any alternate way to sorting data.frame datewise in a descending order?.(not using dplyr) On Thu, Jul 3, 2014 at 12:48 PM, Velappan Periasamy wrote: > Hi A.K > I modified and got the result

Re: [R] Sorting data.frame datewise in a descending order and geting datewise subtotl

2014-07-03 Thread veepsirtt
Hi A.K - library(XML) URL <- " http://money.securebank.in/index.php?option=com_dashboard&view=history&Itemid=56&startdate=01/01/2013&enddate=6/9/2014&exchange=MCX&sid=1"; doc <- htmlParse(URL) tableNodes <- getNodeSet(doc, "//table") dat1 <- readHTMLTable(tableNodes[[

Re: [R] Sorting data.frame datewise in a descending order and geting datewise subtotl

2014-07-02 Thread arun
Hi veepsirtt, If `dat` is the dataset library(dplyr)  dat %>% group_by(DATE) %>% summarize(PROFIT=sum(PROFIT)) %>%  arrange(desc(as.Date(DATE,format="%d/%m/%Y"))) Source: local data frame [4 x 2]     DATE PROFIT 1 02/07/2014  -1350 2 01/07/2014   9400 3 30/06/2014  11325 4 27/06/2014  

Re: [R] Sorting Data Frames in R by multiple columns with a custom order

2013-11-07 Thread arun
If you already have the order stored in a list or so: For example: dat1 <- as.data.frame(mat,stringsAsFactors=FALSE) lst1 <- list(c("OF","ON"), c("US","UK", "WW","BO","BR","CA"), c("P2","P3","P1"),c("S2","S1","S3"))  dat1[] <- lapply(seq_along(lst1),function(i) factor(dat1[,i],levels=lst1[[i]]))

Re: [R] Sorting Data Frames in R by multiple columns with a custom order

2013-11-07 Thread arun
Hi, Not sure whether this helps: dat1 <- as.data.frame(mat,stringsAsFactors=FALSE) dat1$c4 <- factor(dat1$c4,levels=c("OF","ON"))  dat1$c1 <- factor(dat1$c1,levels=c("US","UK","WW","BO","BR","CA"))  dat1$c2 <- factor(dat1$c2, levels=c("P2","P3","P1"))  dat1$c3 <- factor(dat1$c3, levels=c("S2","S1"

Re: [R] Sorting data

2013-08-26 Thread arun
Hi, Hope this is what you meant.. with(dat1,mean(V21[(V2==1|V2==0) & V24<25],na.rm=TRUE))  #[1] 2.8125  sapply(0:1,function(i) with(dat1,mean(V21[V2==i & V24<25],na.rm=TRUE))) #[1] 2.75 3.00 ". who are in condition 1 or 0 (V2) and then vice versa ..."  dat1[,21] # [1]   NA 3.40 3.00 3

Re: [R] Sorting data

2013-08-25 Thread arun
Hi, It's not clear what you really wanted.  May be this helps: dat1<- read.table(text="   V1 V2 V3 V4 V5 V6 V7 V8 V9 V10 V11 V12 V13 V14 V15 V16 V17 V18 V19 V20   V21 V22 V23 V24 V25 V26 1 1  1  3  1 NA NA  1 NA NA   1   2   7   5   3   2 1.0  15  17   5   1    NA   1   2  19   1   1 2

Re: [R] Sorting data.frame and again sorting within data.frame

2013-04-16 Thread Katherine Gobin
Dear Sir, Thanks a lot for your valuable input and guidance. Regards Katherine --- On Mon, 15/4/13, Jeff Newmiller wrote: From: Jeff Newmiller Subject: Re: [R] Sorting data.frame and again sorting within data.frame To: "David Winsemius" , "Katherine Gobin" Cc: r-hel

Re: [R] Sorting data.frame and again sorting within data.frame

2013-04-15 Thread David Winsemius
On Apr 15, 2013, at 9:33 AM, Jeff Newmiller wrote: > Yes, that would be because she converted to Date on the fly in her example, > and so apparently did not need this reminder. I apologize, Iobviously missed that. So the answer was simply to put a minus sign in front of the as.Date() expressi

Re: [R] Sorting data.frame and again sorting within data.frame

2013-04-15 Thread Jeff Newmiller
Yes, that would be because she converted to Date on the fly in her example, and so apparently did not need this reminder. --- Jeff NewmillerThe . . Go Live... DCN:Basics: ##.#

Re: [R] Sorting data.frame and again sorting within data.frame

2013-04-15 Thread David Winsemius
On Apr 14, 2013, at 11:01 PM, Katherine Gobin wrote: > Dear R forum, > > I have a data.frame as defied below - > > df = data.frame(names = c("C", "A", "A", "B", "C", "B", "A", "B", "C"), dates > = c("4/15/2013", "4/13/2013", "4/15/2013", "4/13/2013", "4/13/2013", > "4/15/2013", "4/14/2013",

Re: [R] Sorting data.frame and again sorting within data.frame

2013-04-15 Thread arun
/2013 29 #5 C 4/13/2013 11 A.K. - Original Message - From: arun To: Katherine Gobin Cc: R help Sent: Monday, April 15, 2013 8:57 AM Subject: Re: [R] Sorting data.frame and again sorting within data.frame library(plyr) arrange(df,names,desc(dates)) #  names dates values #1

Re: [R] Sorting data.frame and again sorting within data.frame

2013-04-15 Thread arun
library(plyr) arrange(df,names,desc(dates)) #  names dates values #1 A 4/15/2013 31 #2 A 4/14/2013    102 #3 A 4/13/2013 31 #4 B 4/15/2013 34 #5 B 4/14/2013 47 #6 B 4/13/2013 17 #7 C 4/15/2013 10 #8 C 4/14/2013 29 #9 C 4/13/2013   

Re: [R] Sorting data.frame and again sorting within data.frame

2013-04-15 Thread Jeff Newmiller
The examples in ?order show a method that could be applied if you avoid the decreasing argument and instead convert the Date to numeric for purposes of sorting. --- Jeff NewmillerThe . ..

Re: [R] sorting the VAR model output according to variable names??

2013-04-10 Thread Pfaff, Bernhard Dr.
Dear LondonPhd, assuming that you have assigned 'mod' to your VAR() call, you can run the following: lapply(coef(mod), function(x) x[sort(rownames(x)), ]) In general, the coef-method will retrieve the estimated coefficients and you can then do the reordering to your liking. Best, Bernhard --

Re: [R] sorting/grouping/classification problem?

2013-01-28 Thread Bart Joosen
Hi, after all, brute force seems the way to go. I will use a simplified example to illustrate what I want (dump of dat4 is below): suppose dat4: ID rrt Mnd Result 1 0.45 00.1 1 0.48 00.3 1 1.24 00.5 2 0.45 30.2 2 0.48 30.6 2 1.22 30.4 I want to ge

Re: [R] sorting/grouping/classification problem?

2013-01-25 Thread arun
old 0.3 0.6 1.20 1.80 #4 1.2225    old 0.5 0.4 0.45 0.50 A.K. - Original Message - From: Bart Joosen To: Dennis Murphy ; r-help@r-project.org Cc: Sent: Friday, January 25, 2013 1:48 AM Subject: Re: [R] sorting/grouping/classification problem? Nice suggestion for the extra "Time" column

Re: [R] sorting/grouping/classification problem?

2013-01-25 Thread Bart Joosen
y possible combination of shuffling within certain limits (eg max 10% or so), calculate r2 for each combination and maximize? Seems so brute force and low elegant? Bart > Date: Fri, 25 Jan 2013 10:01:44 -0800 > From: smartpink...@yahoo.com > Subject: Re: [R] sorting/grouping/classific

Re: [R] sorting/grouping/classification problem?

2013-01-24 Thread Bart Joosen
clear now. Thank you all for your suggestions Bart > Date: Thu, 24 Jan 2013 15:01:40 -0800 > Subject: Re: [R] sorting/grouping/classification problem? > From: djmu...@gmail.com > To: bartjoo...@hotmail.com > > Hi: > > Here's a potential workaround: > > # Add

Re: [R] sorting/grouping/classification problem?

2013-01-24 Thread Bart Joosen
dat3 is the dataframe where there are some rrt values merged, which is actually the problem: how on Earth discide which rows van be merged Thanks for your input! Bart -Original Message- From: arun Sent: 24 Jan 2013 20:18:28 GMT To: Bart Joosen Cc: R help Subject: Re: [R] sorting

Re: [R] sorting/grouping/classification problem?

2013-01-24 Thread arun
HI, If I understand your question, "dat3" is not you wanted. Is  it something like this you wanted? library(reshape2)  dcast(dat,rrt~Mnd,value.var="Result") #   rrt   0   3    6    9 #1 0.35  NA  NA 0.05   NA #2 0.36  NA  NA   NA 0.06 #3 0.44  NA  NA 0.40   NA #4 0.45 0.1 0.2   NA 0.60 #5 0.46  N

Re: [R] Sorting a data frame by specifying a vector

2012-10-11 Thread Sarah Goslee
Spring 0.1927715 > #16 Spring 0.1927715 > > The process you describe does not get me there > > Any other recommendations? > > -Original Message- > From: arun [mailto:smartpink...@yahoo.com] > Sent: Thursday, October 11, 2012 10:33 AM > To: ROLL Josh F > Cc: R help >

Re: [R] Sorting a data frame by specifying a vector

2012-10-11 Thread arun
ly, the Obs column has only 4 values.  Do you want to get the means??? A.K. - Original Message - From: ROLL Josh F To: 'arun' Cc: R help Sent: Thursday, October 11, 2012 1:42 PM Subject: RE: [R] Sorting a data frame by specifying a vector Sorry if I wasn't clear but th

Re: [R] Sorting a data frame by specifying a vector

2012-10-11 Thread Bert Gunter
Winter 0.9318599 > #10 Winter 0.9318599 > #14 Winter 0.9318599 > #4 Spring 0.1927715 > #8 Spring 0.1927715 > #12 Spring 0.1927715 > #16 Spring 0.1927715 > > Any other thoughts? > > JR > > > -Original Message- > From: Bert Gunter [mailto:gunter.ber

Re: [R] Sorting a data frame by specifying a vector

2012-10-11 Thread ROLL Josh F
tober 11, 2012 10:33 AM To: ROLL Josh F Cc: R help Subject: Re: [R] Sorting a data frame by specifying a vector Hi, In your dataset, it seems like it is already ordered in the way you wanted to. df.. <- data.frame(Season=rep(c("Summer","Fall","Winter","Spring&

Re: [R] Sorting a data frame by specifying a vector

2012-10-11 Thread arun
Hi, In your dataset, it seems like it is already ordered in the way you wanted to. df.. <- data.frame(Season=rep(c("Summer","Fall","Winter","Spring"),4),Obs= runif(length(rep(c("Summer","Fall","Winter","Spring"),4 #Suppose the order you want is:  vec2<-c("Summer","Winter","Fall","Spring") df1

Re: [R] Sorting a data frame by specifying a vector

2012-10-11 Thread Bert Gunter
?order df[order(yourcolumn, ] -- Bert On Thu, Oct 11, 2012 at 10:08 AM, LCOG1 wrote: > Hello all, >I cannot seem to figure out this seemingly simple procedure. > > I want to sort a data frame by a specified character vector. > > So for : > > df.. <- data.frame(Season=rep(c("Summer","Fall","

Re: [R] sorting dataframe

2012-10-03 Thread killerkarthick
Please show the data set... -- View this message in context: http://r.789695.n4.nabble.com/sorting-dataframe-tp840507p4644857.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list h

Re: [R] Sorting of columns of a matrix

2012-08-29 Thread arun
HI, I guess this might be what you want. dat1<-structure(c(0.585528817843856, 0.709466017509524, 0, -0.453497173462763, 0.605887455840393, -1.81795596770373, 0.630098551068391, -0.276184105225216, -0.284159743943371, -0.919322002474128, -0.116247806352002, 1.81731204370422, 0.370627864257954, 0.520

Re: [R] Sorting of columns of a matrix

2012-08-29 Thread arun
HI, Not sure I understand the last part. Try this: dat1<-structure(c(0.585528817843856, 0.709466017509524, 0, -0.453497173462763, 0.605887455840393, -1.81795596770373, 0.630098551068391, -0.276184105225216, -0.284159743943371, -0.919322002474128, -0.116247806352002, 1.81731204370422, 0.370627864257

Re: [R] Sorting of columns of a matrix

2012-08-29 Thread Nico Met
Met [mailto:nicome...@gmail.com] > *Sent:* Wednesday, August 29, 2012 4:56 PM > *To:* PIKAL Petr > > *Subject:* Re: [R] Sorting of columns of a matrix > > ** ** > > Thanks a lot. > > ** ** > > But I also want to attach row names (if avai

Re: [R] Sorting of columns of a matrix

2012-08-29 Thread PIKAL Petr
Hi > -Original Message- > From: r-help-boun...@r-project.org [mailto:r-help-bounces@r- > project.org] On Behalf Of Nico Met > Sent: Wednesday, August 29, 2012 4:25 PM > To: Berend Hasselman > Cc: r-help@r-project.org > Subject: Re: [R] Sorting of columns of a matrix

Re: [R] Sorting of columns of a matrix

2012-08-29 Thread PIKAL Petr
Hi From: Nico Met [mailto:nicome...@gmail.com] Sent: Wednesday, August 29, 2012 5:27 PM To: PIKAL Petr Cc: r-help Subject: Re: [R] Sorting of columns of a matrix Yes, each column shall have different sequence of row names And what? I do not understand? You still did not describe how do you

Re: [R] Sorting of columns of a matrix

2012-08-29 Thread PIKAL Petr
Met [mailto:nicome...@gmail.com] Sent: Wednesday, August 29, 2012 4:56 PM To: PIKAL Petr Subject: Re: [R] Sorting of columns of a matrix Thanks a lot. But I also want to attach row names (if available) associated with each column. In that case does your second code works in the same way? thanks

Re: [R] Sorting of columns of a matrix

2012-08-29 Thread Nico Met
Please find the require info: set.seed(12345) X<-matrix(rnorm(5*10),nrow=5) dim(X) X [,1] [,2][,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [1,] 1.2774431 -1.2427735 0.81933548 -2.1098586 -1.6726799 -2.2994684 -0.28823228 0.192930

Re: [R] Sorting of columns of a matrix

2012-08-29 Thread Berend Hasselman
On 29-08-2012, at 16:08, Nico Met wrote: > Hello john, > > thanks for the suggestion. Please find an example: > >> X<-matrix(rnorm(5*10),nrow=5) > >> dim(X) > [1] 5 10 >> X > [,1] [,2][,3] [,4] [,5] [,6] > [,7] [,8] [,9] [,10] > [1,

Re: [R] Sorting of columns of a matrix

2012-08-29 Thread Nico Met
Hello john, thanks for the suggestion. Please find an example: > X<-matrix(rnorm(5*10),nrow=5) > dim(X) [1] 5 10 > X [,1] [,2][,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [1,] 1.2774431 -1.2427735 0.81933548 -2.1098586 -1.6726799 -2.2

Re: [R] Sorting of columns of a matrix

2012-08-29 Thread John Kane
Perhaps you could supply the matrix using dput() ? It is a handy way to supply sample data. Just do dput(mydata), copy the results and paste into email. At the moment your matrix is almost unreadable. John Kane Kingston ON Canada > -Original Message- > From: nicome...@gmail.com > Sen

Re: [R] Sorting a data set

2012-05-30 Thread arun
Hi Tony, Try this: dataT<-data.frame(Var1=rep(c("Sole","Lack","ABD","Zad"),rep(5,4)), Var2=rnorm(20,0.5),Var3=runif(20,0.4))  dataT1<-dataT[with(dataT,order(Var1,Var2,Var3)),] dataT1   Var1    Var2  Var3 12  ABD -0.19842353 0.4333720 13  ABD  0.14050814 0.9194297 11  ABD  1.07544531 0.453

Re: [R] Sorting a data set

2012-05-30 Thread jim holtman
If you want to sort by the columns with the names 'var1' and 'var2', you would do: newdata <- data[order(data$var1, data$var2), ] On Wed, May 30, 2012 at 6:07 PM, tony.anderson wrote: > I am a novice user of R and am stumbling on how to order a dataset produced > during my session. > > I have

Re: [R] Sorting strings

2012-02-20 Thread statquant2
NICE DDE It solves my problem ! Awesome stuff -- View this message in context: http://r.789695.n4.nabble.com/Sorting-strings-tp4403696p4404424.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https:

Re: [R] Sorting strings

2012-02-20 Thread Ted Harding
On 20-Feb-2012 Petr Savicky wrote: > On Mon, Feb 20, 2012 at 05:55:30AM -0800, statquant2 wrote: >> I did, but this does not give the answer to my question... >> Anybody knows how to tweack the behaviour of sort or how to do ? > > Hi. > Try this > > Sys.setlocale("LC_COLLATE", "C") > > This c

Re: [R] Sorting strings

2012-02-20 Thread De-Jian Zhao
On 2012-2-20 23:15, Rui Barradas wrote: Could it be OS related? Yes, it seems. I tried it on my local windows xp and redhat linux server, and got different results. Hope it will be fixed in the future versions. Maybe we should keep alert to check whether the results are consistent when trans

Re: [R] Sorting strings

2012-02-20 Thread De-Jian Zhao
Sorry, just made a mistake. This is the result from windows xp. > sort(c("X.","X0B")) [1] "X." "X0B" > sort(c("X.Z","X0B.Z")) [1] "X.Z" "X0B.Z" > R.version _ platform i386-pc-mingw32 arch i386 os mingw32 system i386, mingw32 status major

Re: [R] Sorting strings

2012-02-20 Thread Petr Savicky
On Mon, Feb 20, 2012 at 04:56:21PM +0100, Petr Savicky wrote: > On Mon, Feb 20, 2012 at 05:55:30AM -0800, statquant2 wrote: > > I did, but this does not give the answer to my question... > > Anybody knows how to tweack the behaviour of sort or how to do ? > > Hi. > > Try this > > Sys.setlocale

Re: [R] Sorting strings

2012-02-20 Thread De-Jian Zhao
It seems OS-dependent. I got different results when trying it on windows xp and Redhat linux. > R.version _ platform x86_64-unknown-linux-gnu arch x86_64 os linux-gnu system x86_64, linux-gnu status major 2 minor 9.1 year

Re: [R] Sorting strings

2012-02-20 Thread statquant2
Ok I have : R) str(R.Version()) List of 13 $ platform : chr "x86_64-unknown-linux-gnu" $ arch : chr "x86_64" $ os: chr "linux-gnu" $ system: chr "x86_64, linux-gnu" $ status: chr "" $ major : chr "2" $ minor : chr "12.2" $ year

Re: [R] Sorting strings

2012-02-20 Thread Rui Barradas
Hello, statquant2 wrote > > Ok so it changed from 2.12.2 to 2.14.1 ?? > Can somebody tell me how to modify my sort or whatever to get the save > resilt that I would get in 2.14.1 ? > > Cheers > I don't know about 2.12.2 but for 2.12.0 I get: > R.version _

Re: [R] Sorting strings

2012-02-20 Thread Petr Savicky
On Mon, Feb 20, 2012 at 05:55:30AM -0800, statquant2 wrote: > I did, but this does not give the answer to my question... > Anybody knows how to tweack the behaviour of sort or how to do ? Hi. Try this Sys.setlocale("LC_COLLATE", "C") This comes from ?locale and reads there Sys.setloca

Re: [R] Sorting strings

2012-02-20 Thread R. Michael Weylandt
I don't *think* it's version specific, but rather it depends on your (still unstated) locale, as the documentation goes to great lengths to point out. Change that and you might see different behaviors. Michael On Mon, Feb 20, 2012 at 8:55 AM, statquant2 wrote: > I did, but this does not give the

Re: [R] Sorting strings

2012-02-20 Thread statquant2
I did, but this does not give the answer to my question... Anybody knows how to tweack the behaviour of sort or how to do ? -- View this message in context: http://r.789695.n4.nabble.com/Sorting-strings-tp4403696p4404091.html Sent from the R help mailing list archive at Nabble.com. _

Re: [R] Sorting strings

2012-02-20 Thread statquant2
Ok so it changed from 2.12.2 to 2.14.1 ?? Can somebody tell me how to modify my sort or whatever to get the save resilt that I would get in 2.14.1 ? Cheers -- View this message in context: http://r.789695.n4.nabble.com/Sorting-strings-tp4403696p4403858.html Sent from the R help mailing list arch

Re: [R] Sorting strings

2012-02-20 Thread Enrico Schumann
See ?Comparison, which holds some warnings about what to expect when sorting strings. Am 20.02.2012 11:51, schrieb Petr Savicky: On Mon, Feb 20, 2012 at 02:18:42AM -0800, statquant2 wrote: Hi all, I am having difficulties to understand how R sort strings: If I do R) sort(c("X.","X0B")) [1]

  1   2   3   >