Re: [R] sort

2020-05-15 Thread Rui Barradas
Hello, Here is a dplyr solution. arrange() sorts by name and desc(ddate) and top_n keeps the first 2 after grouping by ddate. Then it's a matter of being careful with diff() in the summarise instruction. library(dplyr) DF1 %>% mutate(ddate = as.Date(ddate)) %>% arrange(name, desc(ddate)

Re: [R] sort

2020-05-14 Thread Jim Lemon
Hi Val, Your problem is keeping the orders straight. You want dates decreasing and names increasing: DF1<-read.table(text="name ddate A 2019-10-28 A 2018-01-25 A 2020-01-12 A 2017-10-20 B 2020-11-20 B 2019-10-20 B 2017-05-20 B 2020-01-20 C 2009-10-01 ",header=TRUE) DF1$

[R] sort

2020-05-14 Thread Val
HI All, I have a sample of data frame DF1<-read.table(text="name ddate A 2019-10-28 A 2018-01-25 A 2020-01-12 A 2017-10-20 B 2020-11-20 B 2019-10-20 B 2017-05-20 B 2020-01-20 c 2009-10-01 ",header=TRUE) 1. I want sort by name and ddate on decreasing order and the output

Re: [R] sort()ing strings

2016-10-13 Thread peter dalgaard
> On 13 Oct 2016, at 13:00 , Martin Maechler wrote: > > which I do find strange, indeed, given your sessionInfo which > contains > LC_COLLATE=en_US.UTF-8 > One of the _really_ strange things about localization is that there is no standardization. Names don't necessarily mean the same th

Re: [R] sort()ing strings

2016-10-13 Thread Bob O'Hara
Thanks - strangely capabilities("ICU") is FALSE (I'm using ubuntu 16.04, and icu-devtools is installed). So I guess I'll conclude that there's something odd, but I don't want to delve into these issues (a new locale & new computer for me in a couple of months). Bob On 13 October 2016 at 13:00, Ma

Re: [R] sort()ing strings

2016-10-13 Thread Martin Maechler
> Bob O'Hara > on Thu, 13 Oct 2016 11:55:04 +0200 writes: > Yes, thanks. That seems to be it: > thing <- c("M1", "M2", "M.1", "M.2") >> sort(thing) > [1] "M1" "M.1" "M2" "M.2" which I do find strange, indeed, given your sessionInfo which contains LC_COLLATE=e

[R] Sort a data table

2016-08-11 Thread Nelly Reduan
Hello, I have some problems to sort a large data table. In particular, I would like to sort a data table in such a way that the duplicated values in two columns are disposed one below the other and if possible in an ascending order (especially for the column "Date"). An example with a short dat

Re: [R] Sort data and symbol change in Jitter plot (ggplot2)

2015-05-06 Thread Luis Fernando García
Thanks all of you guys! Your answers were very useful! Thanks for the answer John, but I will try to keep the dotplot, but it is very useful to know both techniques anyway :) Petr, many thanks for your help, it was just what I needed, btw, the arrangment based on the median was a headache for me

Re: [R] Sort data and symbol change in Jitter plot (ggplot2)

2015-05-05 Thread PIKAL Petr
Hi answeres in line > -Original Message- > From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Luis > Fernando García > Sent: Tuesday, May 05, 2015 9:34 AM > To: r-help@r-project.org > Subject: [R] Sort data and symbol change in Jitter plot (ggplot2)

[R] Sort data and symbol change in Jitter plot (ggplot2)

2015-05-05 Thread Luis Fernando García
Dear R experts, First than all I want to thank your expertise and for sharing your knowledge with the people who are starting. Recently I have been working on a new plot style (Jitterplot) but have still some issues when making two basic functions. First than all I want to change the symbol acco

Re: [R] sort adjacency matrix

2015-04-06 Thread David Winsemius
- >> David L Carlson >> Department of Anthropology >> Texas A&M University >> College Station, TX 77840-4352 >> >> >> -Original Message- >> From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Ragia Ibrahim >> Sent:

Re: [R] sort adjacency matrix_with data

2015-04-06 Thread Ragia Ibrahim
6 Apr 2015 19:20:02 +0100 > From: ruipbarra...@sapo.pt > To: ragi...@hotmail.com; r-help@r-project.org > Subject: Re: [R] sort adjacency matrix > > Hello, > > You should have used ?dput to post your data example. > Since you haven't, I've made up one. > >

Re: [R] sort adjacency matrix

2015-04-06 Thread Rui Barradas
Hello, You should have used ?dput to post your data example. Since you haven't, I've made up one. set.seed(4795) mat <- matrix(sample(0:1, 24, replace = TRUE), nrow = 6) mat inx <- order(rowSums(mat), decreasing = TRUE) mat[inx, ] Hope this helps, Rui Barradas Em 06-04-2015 18:18, Ragia Ibr

Re: [R] sort adjacency matrix

2015-04-06 Thread Bert Gunter
of Anthropology > Texas A&M University > College Station, TX 77840-4352 > > > -Original Message- > From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Ragia Ibrahim > Sent: Monday, April 6, 2015 12:18 PM > To: r-help@r-project.org > Subject: [R] sort adj

Re: [R] sort adjacency matrix

2015-04-06 Thread David L Carlson
gy Texas A&M University College Station, TX 77840-4352 -Original Message- From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Ragia Ibrahim Sent: Monday, April 6, 2015 12:18 PM To: r-help@r-project.org Subject: [R] sort adjacency matrix Dear group i have the following ma

[R] sort adjacency matrix

2015-04-06 Thread Ragia Ibrahim
Dear group i have the following matrix 1 . . 1 . . 1 . . . . 2 . . . . . . 1 . . . 3 1 . . . 1 . . 1 . 1 4 . . . . . 1 . . . . 5 . . 1 . . . . . . 1 6 1 . . 1 . . . . 1 . 7 . 1 . . . . . 1 . . 8 . . 1 . . . 1 . . 1 9 . . . . . 1 . . . 1 10 . . 1 . 1 . . 1 1 . I want to sort it according

Re: [R] sort by decreasing columns?

2014-12-13 Thread Jeff Newmiller
In general, different rows would sort in different orders. Your example does not illustrate how you would want to address such a problem. Here I assume you are only interested in sorting by the values in the first row. dta <- data.frame(a=c(2,3), b=c(3,5), c=c(8,9)) dta[,order(unlist(dta[1,]),de

[R] sort by decreasing columns?

2014-12-13 Thread Nia Gupta via R-help
Hello, I have a data frame that looks like this:    a  b    c 1    2   3    8 2    3   5    9 I was wondering if it was possible to reorder the columns by decreasing values so the new data frame would look like this:    c b    a 1    8 3    2 2  

Re: [R] sort a data.frame in a different way

2014-10-22 Thread Sven E. Templer
seems like a transpose, so use ?t t(your.data.frame) On 22 October 2014 11:34, Matthias Weber wrote: > Hello together, > > i have a little problem. Maybe anyone can help me. > > I have a data. frame which look like this one: > 1000 1001 10021003 > 15 6 12

[R] sort a data.frame in a different way

2014-10-22 Thread Matthias Weber
Hello together, i have a little problem. Maybe anyone can help me. I have a data. frame which look like this one: 1000 1001 10021003 15 6 1211 24 3 81 What i need is a data.frame, which looks like this one. The Column na

Re: [R] sort order of a character sequence is different on windose and linux (linux result)

2014-07-08 Thread Witold E Wolski
>From my reading of http://r.789695.n4.nabble.com/internal-string-comparison-Scollate-td4687584.html they have good arguments to ask for Scollate whatever it is in the R public API. And from my point of view R would benefit from a tight integration of data.table. Without data.table R is very impr

Re: [R] sort order of a character sequence is different on windose and linux (linux result)

2014-07-06 Thread Duncan Murdoch
On 06/07/2014, 7:56 AM, Witold E Wolski wrote: > This is the info I got from the data.table developers... Seems that > they did have tried to find a more elegant solution solution.: >From my reading of the response below, data.table doesn't use R's sort() function to do their sorting. You should

Re: [R] sort order of a character sequence is different on windose and linux (linux result)

2014-07-06 Thread Witold E Wolski
This is the info I got from the data.table developers... Seems that they did have tried to find a more elegant solution solution.: data.table used to support this until 1.8.6. But since Scollate became not a part of authorised R-API (IIUC) anymore at some point, data.table only supports sort/orde

Re: [R] sort order of a character sequence is different on windose and linux (linux result)

2014-07-06 Thread Duncan Murdoch
On 06/07/2014, 7:19 AM, Witold E Wolski wrote: > It seems that the package I am developing depends on the locale "C" > because of interactions with other packages (data.table). > > So I would like to set the locale to "C" as soon as the package is loaded. > Where can I do it .. I could of course s

Re: [R] sort order of a character sequence is different on windose and linux (linux result)

2014-07-06 Thread Witold E Wolski
It seems that the package I am developing depends on the locale "C" because of interactions with other packages (data.table). So I would like to set the locale to "C" as soon as the package is loaded. Where can I do it .. I could of course set it in every function in my package but... ___

Re: [R] sort order of a character sequence is different on windose and linux (linux result)

2014-07-06 Thread Duncan Murdoch
On 06/07/2014, 6:30 AM, Witold E Wolski wrote: > This is the result of sorting a character sequence on a linux box > (with R . 3.10) See ?sort. The sort order depends on your locale. Set it to "C" for consistent ordering if that is important to you. For example, on my system: > "B" < "a" [1] F

[R] sort order of a character sequence is different on windose and linux (windows result)

2014-07-06 Thread Witold E Wolski
And here is the result when sorting the same sequence on a windows box: > bla = read.table("xx.txt",stringsAsFactors=F) > bla = bla[,1] > bla[1:10] [1] "1000_DGFVALSK_2_run0" "1000_DGFVALSK_2_run0" "1000_DGFVALSK_2_run0" "1000_DGFVALSK_2_run0" [5] "1000_DGFVALSK_2_run0" "1000_DGFVALSK_2_r

[R] sort order of a character sequence is different on windose and linux (linux result)

2014-07-06 Thread Witold E Wolski
This is the result of sorting a character sequence on a linux box (with R . 3.10) > bla = read.table("xx.txt",stringsAsFactors=F) > bla = bla[,1] > bla[1:10] [1] "1000_DGFVALSK_2_run0" "1000_DGFVALSK_2_run0" "1000_DGFVALSK_2_run0" "1000_DGFVALSK_2_run0" "1000_DGFVALSK_2_run0" [6] "1000_DGFVA

Re: [R] sort() depends on locale (and platform and build)

2014-06-15 Thread Marius Hofert
Hi, ... so something like this? [in foo.R] old.coll <- Sys.getlocale("LC_COLLATE") Sys.setlocale("LC_COLLATE", locale="C") Sys.setlocale("LC_COLLATE", locale=old.coll) Cheers, Marius __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/

Re: [R] sort() depends on locale (and platform and build)

2014-06-15 Thread Prof Brian Ripley
On 15/06/2014 17:34, Marius Hofert wrote: Hi, Thanks for you help. I use R-devel under Ubuntu 14.04, here is the output of sessionInfo(): sessionInfo() R Under development (unstable) (2014-06-02 r65832) Platform: x86_64-unknown-linux-gnu (64-bit) locale: [1] LC_CTYPE=en_US.UTF-8 LC_N

Re: [R] sort() depends on locale (and platform and build)

2014-06-15 Thread Marius Hofert
Hi, Thanks for you help. I use R-devel under Ubuntu 14.04, here is the output of sessionInfo(): > sessionInfo() R Under development (unstable) (2014-06-02 r65832) Platform: x86_64-unknown-linux-gnu (64-bit) locale: [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C [3] LC_TIME=en_US.UTF-8LC_C

Re: [R] sort() depends on locale

2014-06-15 Thread Prof Brian Ripley
On 15/06/2014 12:16, Duncan Murdoch wrote: On 15/06/2014, 1:15 AM, Marius Hofert wrote: Hi, If I use invisible(Sys.setlocale("LC_COLLATE", "C")) in ~/.Rprofile, then sort(c("L.Y", "Lu", "L.Q")) [1] "L.Q" "L.Y" "Lu" whereas using invisible(Sys.setlocale("LC_COLLATE", "en_US.UTF-8")) results

Re: [R] sort() depends on locale

2014-06-15 Thread Duncan Murdoch
On 15/06/2014, 1:15 AM, Marius Hofert wrote: > Hi, > > If I use invisible(Sys.setlocale("LC_COLLATE", "C")) in ~/.Rprofile, then > >> sort(c("L.Y", "Lu", "L.Q")) > [1] "L.Q" "L.Y" "Lu" > > whereas using invisible(Sys.setlocale("LC_COLLATE", "en_US.UTF-8")) results in > >> sort(c("L.Y", "Lu", "L

Re: [R] sort() depends on locale (and platform and build)

2014-06-14 Thread Prof Brian Ripley
On 15/06/2014 07:45, Pascal Oettli wrote: Hello, Please provide your sessionInfo(). I don't see this issue with R 3.1.0 Patched on Linux. Nor on any of my platforms. We would also need to know if ICU was found when R was installed: see ?Comparison . Regards, Pascal On Sun, Jun 15, 2014

Re: [R] sort() depends on locale

2014-06-14 Thread Pascal Oettli
Hello, Please provide your sessionInfo(). I don't see this issue with R 3.1.0 Patched on Linux. Regards, Pascal On Sun, Jun 15, 2014 at 2:15 PM, Marius Hofert wrote: > Hi, > > If I use invisible(Sys.setlocale("LC_COLLATE", "C")) in ~/.Rprofile, then > >> sort(c("L.Y", "Lu", "L.Q")) > [1] "L.Q"

[R] sort() depends on locale

2014-06-14 Thread Marius Hofert
Hi, If I use invisible(Sys.setlocale("LC_COLLATE", "C")) in ~/.Rprofile, then > sort(c("L.Y", "Lu", "L.Q")) [1] "L.Q" "L.Y" "Lu" whereas using invisible(Sys.setlocale("LC_COLLATE", "en_US.UTF-8")) results in > sort(c("L.Y", "Lu", "L.Q")) [1] "L.Q" "Lu" "L.Y" I know this issue has appeared alr

Re: [R] Sort data by month

2013-05-22 Thread arun
Regards, Arun   From: "zilefacel...@yahoo.com" To: arun Cc: R help Sent: Thursday, May 23, 2013 1:42 AM Subject: Re: Re: [R] Sort data by month Hi AK, Thanks so much. Problem well handled. Atem. -- Original Message -

Re: [R] Sort data by month

2013-05-22 Thread arun
ntical(datNew,datNew2) #[1] TRUE A.K. From: Zilefac Elvis To: arun Cc: R help Sent: Thursday, May 23, 2013 12:32 AM Subject: Re: [R] Sort data by month Hi Ak, I seems to work correctly with your data. Please try it on my data (attached). My data is month

Re: [R] Sort data by month

2013-05-22 Thread Zilefac Elvis
. From: arun To: Zilefac Elvis Cc: R help Sent: Wednesday, May 22, 2013 8:47 PM Subject: Re: [R] Sort data by month Hi, May be this helps. date1<-seq.Date(as.Date("01/01/2000",format="%d/%m/%Y"),as.Date("31/12/2010",format="%d/%m/%Y&q

Re: [R] Sort data by month

2013-05-22 Thread arun
2010-12-24 26.17041 4012 2010-12-25 24.76579 4013 2010-12-26 25.49849 4014 2010-12-27 23.64199 4015 2010-12-28 23.97338 4016 2010-12-29 24.96617 4017 2010-12-30 24.07872 4018 2010-12-31 25.25245 A.K. - Original Message - From: Zilefac Elvis To: "r-help@r-project.org" Cc: Sent:

[R] Sort data by month

2013-05-22 Thread Zilefac Elvis
Hello, I have a 'zoo' object containing dates [dd/mm/yr] in the first column and values in the second column. I tried as.Date but did not succeed. Here is an example of date format  01/01/2000 01/02/2000 ... 01/12/2000 01/01/2001 01/02/2001 ... 01/12/2000   etc. I would like to sort all Jans fro

Re: [R] sort matrix based on a specific order

2013-01-10 Thread Ioannis Kosmidis
mat[match(ind, mat[, 2]), ] [,1] [,2] [1,] "y" "c" [2,] "x" "b" [3,] "z" "d" [4,] "w" "a" though you need to take care if you have cases where ind will contains letters that are not in mat[, 2] and so on (check ?match). Best, I On 10 Jan 2013, at 18:21, array chip wrote: > Hi I h

Re: [R] sort matrix based on a specific order

2013-01-10 Thread arun
HI, Try this:  mat[match(ind,mat[,2]),]   #   [,1] [,2] #[1,] "y"  "c" #[2,] "x"  "b" #[3,] "z"  "d" #[4,] "w"  "a" A.K. - Original Message - From: array chip To: "r-help@r-project.org"

Re: [R] sort matrix based on a specific order

2013-01-10 Thread array chip
Thank you all for the suggestions, fantastic! From: Rui Barradas Cc: "r-help@r-project.org" Sent: Thursday, January 10, 2013 10:32 AM Subject: Re: [R] sort matrix based on a specific order Hello, Try the following. order() gives you a permutat

Re: [R] sort matrix based on a specific order

2013-01-10 Thread Rui Barradas
Hello, Try the following. order() gives you a permutation of the vector 'ind' and to order that permutation gives its inverse. mat <- cbind(c('w','x','y','z'),c('a','b','c','d')) ind <- c('c','b','d','a') ord <- order(ind) mat[order(ord), ] Hope this helps, Rui Barradas Em 10-01-2013 18:21,

Re: [R] sort matrix based on a specific order

2013-01-10 Thread jim holtman
more complete example > mat<-cbind(c('w','x','y','z'),c('a','b','c','d')) > matOrd <- mat[order(factor(mat[,2], levels = c('c', 'b', 'd','a'))), ] > matOrd [,1] [,2] [1,] "y" "c" [2,] "x" "b" [3,] "z" "d" [4,] "w" "a" > On Thu, Jan 10, 2013 at 1:21 PM, array chip wrote: > Hi I have a

Re: [R] sort matrix based on a specific order

2013-01-10 Thread William Dunlap
; [2,] "x" "b" [3,] "z" "d" [4,] "w" "a" Bill Dunlap Spotfire, TIBCO Software wdunlap tibco.com > -Original Message- > From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On > Behalf &

Re: [R] sort matrix based on a specific order

2013-01-10 Thread jim holtman
Define them as factors with a specified order for your sorting. e.g. x <- factor(your_data, levels = c('c', 'b','d', 'a')) On Thu, Jan 10, 2013 at 1:21 PM, array chip wrote: > Hi I have a character matrix with 2 columns A and B, If I want to sort the > matrix based on the column B, but based

[R] sort matrix based on a specific order

2013-01-10 Thread array chip
Hi I have a character matrix with 2 columns A and B, If I want to sort the matrix based on the column B, but based on a specific order of characters: mat<-cbind(c('w','x','y','z'),c('a','b','c','d')) ind<-c('c','b','d','a') I want "mat" to be sorted by the sequence in "ind": [,1] [,2] [1,]

Re: [R] Sort or Permutate

2012-09-11 Thread arun
Hasselman To: Alaios Cc: R help Sent: Tuesday, September 11, 2012 11:00 AM Subject: Re: [R] Sort or Permutate On 11-09-2012, at 13:13, Alaios wrote: > Dear all, > I am having a struct that contains on the first column file names and on the > second column a number which is a "

Re: [R] Sort or Permutate

2012-09-11 Thread Bert Gunter
Ah, but note that the OP's 2nd column is character, not numeric... And we don't know what the "struct" is (a matrix or data frame?? --does the OP know the difference?). Has Alaios perused "An Introduction to R" where he/she might have gained some enlightenment that would have obviated the need to p

Re: [R] Sort or Permutate

2012-09-11 Thread Berend Hasselman
On 11-09-2012, at 13:13, Alaios wrote: > Dear all, > I am having a struct that contains on the first column file names and on the > second column a number which is a "rating" of the file on first column > > A small subset looks like that > > small > [,1]

[R] Sort or Permutate

2012-09-11 Thread Alaios
Dear all, I am having a struct that contains on the first column file names and on the second column a number which is a "rating" of the file on first column A small subset looks like that small [,1]   

Re: [R] Sort 1-column dataframe with rownames

2012-06-08 Thread arun
Hi, Try this, df.sort<-apply(df,2,sort) > df.sort    x A  1 D  2 I  2 B  3 J  8 G 12 H 33 E 34 F 44 C 51 df.sort<-as.data.frame(df.sort) A.K. - Original Message - From: Johannes Radinger To: R-help@r-project.org Cc: Sent: Friday, June 8, 2012 3:22 AM Subject: [R] Sort

Re: [R] Sort 1-column dataframe with rownames

2012-06-08 Thread Johannes Radinger
Hi Achim, thank you for your good explanation and the solution to my question... cheers, /j Original-Nachricht > Datum: Fri, 8 Jun 2012 09:30:42 +0200 (CEST) > Von: Achim Zeileis > An: Johannes Radinger > CC: R-help@r-project.org > Betreff: Re: [R] Sort 1-c

Re: [R] Sort 1-column dataframe with rownames

2012-06-08 Thread Ivan Calandra
Hi Johannes, You need to add the drop=FALSE argument in order to keep the structure: df.sort <- df[order(df[,"x"]), , drop=FALSE] ## don't forget the extra comma See ?"[" for details HTH, Ivan -- Ivan CALANDRA Université de Bourgogne UMR CNRS/uB 6282 Biogéosciences 6 Boulevard Gabriel 21000

Re: [R] Sort 1-column dataframe with rownames

2012-06-08 Thread Achim Zeileis
On Fri, 8 Jun 2012, Johannes Radinger wrote: Hi, I have a 1-column dataframe with rownames and I want to sort it based on the single column. The typical procedure that is recommended in diverse posts is to use order in the index. But that "destroys" my dataframe structure. Probabaly it is a ver

[R] Sort 1-column dataframe with rownames

2012-06-08 Thread Johannes Radinger
Hi, I have a 1-column dataframe with rownames and I want to sort it based on the single column. The typical procedure that is recommended in diverse posts is to use order in the index. But that "destroys" my dataframe structure. Probabaly it is a very simple solution. Here is a short reproducable

Re: [R] Sort across multiple csv

2012-05-18 Thread David Winsemius
On May 18, 2012, at 12:56 PM, Matthew Ouellette wrote: Dear R help list, I am very new to R and I apologize in advance if this has been answered before. I have done my best to google/R search what I need but no luck. Here is what I am attempting: I have hundreds of .csv files that I nee

Re: [R] Sort across multiple csv

2012-05-18 Thread Rui Barradas
Hello, Try the following. # Make some data alldata <- list(matrix(rnorm(12), ncol=3), matrix(sample(100), ncol=10)) (alldata <- lapply(alldata, function(x){colnames(x) <- c("Name", LETTERS[2:ncol(x)]); x})) # This does the trick all.order <- lapply(alldata, function(x) order(x[, "Name"])) lappl

Re: [R] Sort across multiple csv

2012-05-18 Thread MacQueen, Don
You appear to have a good start. If you type alldata[[1]] do you get what you expect for the first file? This is not tested, but I would start with something like this: sorteddata <- lapply(alldata, function(df) df[order(df$Name),] ) ## then this will overwrite for (id in seq(filenames)) {

[R] Sort across multiple csv

2012-05-18 Thread Matthew Ouellette
Dear R help list, I am very new to R and I apologize in advance if this has been answered before. I have done my best to google/R search what I need but no luck. Here is what I am attempting: I have hundreds of .csv files that I need to sort based on a single column of alphanumeric data. All o

Re: [R] Sort out number on value

2012-04-20 Thread R. Michael Weylandt
This really has little to do with sorting, but can be much more easily done with logical subscripting: x[x < 20] which I read as "x such that x is less than 20". Hope this helps, Michael On Fri, Apr 20, 2012 at 6:26 AM, Yellow wrote: > Can anyone help me maybe with a question I can seem to fin

Re: [R] Sort out number on value

2012-04-20 Thread Milan Bouchet-Valat
Le vendredi 20 avril 2012 à 03:26 -0700, Yellow a écrit : > Can anyone help me maybe with a question I can seem to find an answer on. > > I have this: x = c(1, 5, 70, 53, 7, 29, 75, 37, 30, 11) > > And I would like to have the numbers above 20 selected out. > But I can't find what code I need

[R] Sort out number on value

2012-04-20 Thread Yellow
Can anyone help me maybe with a question I can seem to find an answer on. I have this: x = c(1, 5, 70, 53, 7, 29, 75, 37, 30, 11) And I would like to have the numbers above 20 selected out. But I can't find what code I need for that I tried sort(), but then I can't fill in I only need tho

Re: [R] sort list

2012-03-14 Thread sybil kennelly
O yea sure. So for example: grid <- read.table("table") ( i havent printed the output, as the table is 20,000 rows X 60 columns) point_of_interest <- c("row1", "row2") therefore all the other points in plot(table) are labelled green, but these two are labelled red. But at the minute, becaus

Re: [R] sort list

2012-03-14 Thread R. Michael Weylandt
Errr...I'm still not sure how plot(table) gives you read and green points, but it sounds like the easiest thing to do would be to use the points() function to come back in and put new green points over the red ones. E.g. plot(runif(5000), runif(5000)) points(c(0.5, 0.25), c(0.5, 0.75), col = 2, pc

Re: [R] sort list

2012-03-14 Thread R. Michael Weylandt
What sort of plot are you using? I'm not really clear on what your data as a whole look like: if you use dput() you can create a representation and we can work from there. In addition to the resources Josh recommended, the following sites can direct you to all sorts of graphical goodies, all of wh

Re: [R] sort list

2012-03-14 Thread sybil kennelly
I appreciate the reading Thank you. May i ask one final question. If i have: matrix: > var1var2 var3 > cell1x x x > cell2x x x > cell3x x x > > cell4 > > . > . > . > . > cell100 and: vector1 <- c("cell1, "cell5",cell19", "cell

Re: [R] sort list

2012-03-13 Thread sybil kennelly
Thanks Josh. I'm quite new, just wondering re:factor levels? In this example (shamelessly stolen from the internet): *schtyp* [1] 0 0 1 0 0 0 1 0 1 0 1 1 1 1 0 0 1 1 1 0 *schtyp.f <- factor(schtyp, labels = c("private", "public")) schtyp.f* [1] private private public private private private p

Re: [R] sort list

2012-03-13 Thread Joshua Wiley
On Tue, Mar 13, 2012 at 5:15 AM, sybil kennelly wrote: > Thanks Josh. I'm quite new, just wondering re:factor levels? > > In this example (shamelessly stolen from the internet): > > schtyp > > [1] 0 0 1 0 0 0 1 0 1 0 1 1 1 1 0 0 1 1 1 0 > > schtyp.f <- factor(schtyp, labels = c("private", "public"

Re: [R] sort list

2012-03-13 Thread Joshua Wiley
Hi Sybil, You cannot turn a list into a factor. You could do: cell_data <-c('cell1','cell2') factor_list <- factor(cell_data) or if you already have a list, unlist() or as.vector() may convert it into a vector that you can then convert to a factor. Cheers, Josh On Tue, Mar 13, 2012 at 4:29 A

[R] sort list

2012-03-13 Thread sybil kennelly
Hello can anyone help please? i read two words "cell1", "cell2" into a list. I want to turn this list into a factor. > cell_data <-list(c('cell1','cell2')) > cell_data [[1]] [1] "cell1" "cell2" > factor_list <- factor(cell_data) Error in sort.list(y) : 'x' must be atomic for 'sort.list' Have

Re: [R] sort dates

2012-03-09 Thread Gabor Grothendieck
On Fri, Mar 9, 2012 at 8:35 AM, carol white wrote: > Hello, > How is it possible to sort dates in R? > Your question has already been answered but note that if your data is a time series and you represent it using zoo it will automatically be sorted. Here dates is in reverse chronological order

Re: [R] sort dates

2012-03-09 Thread Robert Baer
How is it possible to sort dates in R? Try this: a = sample(as.Date(1:100, origin = '2012-01-01'),15) a [1] "2012-01-31" "2012-01-22" "2012-03-18" "2012-03-05" "2012-03-17" [6] "2012-03-08" "2012-01-08" "2012-01-20" "2012-03-01" "2012-03-21" [11] "2012-02-17" "2012-01-17" "2012-02-12" "2012-02

Re: [R] sort dates

2012-03-09 Thread Petr PIKAL
Hi > > Hello, > How is it possible to sort dates in R? You mean sort? Or order? Something like: > dd <-sample(Sys.Date()-1:10) > dd [1] "2012-03-04" "2012-03-05" "2012-02-29" "2012-03-01" "2012-03-02" [6] "2012-03-08" "2012-03-03" "2012-02-28" "2012-03-06" "2012-03-07" > sort(dd) [1] "2012-0

Re: [R] sort dates

2012-03-09 Thread R. Michael Weylandt
? sort x <- c(Sys.Date(), Sys.Date() + 1, Sys.Date() - 1) print(x) print(sort(x)) Michael On Fri, Mar 9, 2012 at 8:35 AM, carol white wrote: > Hello, > How is it possible to sort dates in R? > > Cheers, > > Carol > > __ > R-help@r-project.org mailin

[R] sort dates

2012-03-09 Thread carol white
Hello, How is it possible to sort dates in R? Cheers, Carol __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, s

Re: [R] sort() function for dates

2011-12-13 Thread David Winsemius
On Dec 13, 2011, at 3:43 AM, Ana wrote: Thanks people! another question, is there something similar to sort for dates? sort(x, decreasing = FALSE, ...) So what makes you even suspect that there wasn't a sort method for dates? -- David. On Tue, Dec 13, 2011 at 8:34 AM, Jorge I Velez >

[R] sort() function for dates

2011-12-13 Thread Ana
Thanks people! another question, is there something similar to sort for dates? sort(x, decreasing = FALSE, ...) On Tue, Dec 13, 2011 at 8:34 AM, Jorge I Velez wrote: > Hi Ana, > > Check section 4 of http://www.jstatsoft.org/v40/i03/paper for more > alternatives. > > HTH, > Jorge.- > > > On Mon

Re: [R] sort a 3 dimensional array across third dimension ?

2011-02-18 Thread rex.dwyer
c(3,4,5)) >a >for (i in 1:dim(a)[1]) > for (j in 1:dim(a)[2]) > a[i,j,] = sort(a[i,j,]) >a > >Is that what you want? > >Subject: [R] sort a 3 dimensional array across third dimension ? > >I'm attempting to sort a 3 dimensional array that looks like this >

Re: [R] sort a 3 dimensional array across third dimension ?

2011-02-18 Thread jamaas
Thanks Claudia (and all others!0 This works beautifully! The instructions for aperm are a bit vauge! J -- View this message in context: http://r.789695.n4.nabble.com/sort-a-3-dimensional-array-across-third-dimension-tp3312612p3313126.html Sent from the R help mailing list archive at Nabble.co

Re: [R] sort a 3 dimensional array across third dimension ?

2011-02-18 Thread rex.dwyer
,]) a Is that what you want? -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Maas James Dr (MED) Sent: Friday, February 18, 2011 8:01 AM To: r-help@r-project.org Subject: [R] sort a 3 dimensional array across third dimension ?

Re: [R] sort a 3 dimensional array across third dimension ?

2011-02-18 Thread Maas James Dr (MED)
a[i,j,] = sort(a[i,j,]) >a > >Is that what you want? > >Subject: [R] sort a 3 dimensional array across third dimension ? > >I'm attempting to sort a 3 dimensional array that looks like this >> x >, , 1 > [,1] [,2] >[1,]99 >[2,]79 >,

Re: [R] sort a 3 dimensional array across third dimension ?

2011-02-18 Thread Claudia Beleites
Dear James, this is what I understood your sorting along the third dimension to be: > x <- array(c(9, 9, 7, 9, 6, 5, 4, 6, 2, 1, 3, 2), dim = list(2, 2, 3)) > y <- apply (x, 1:2, sort) > y , , 1 [,1] [,2] [1,]21 [2,]65 [3,]99 , , 2 [,1] [,2] [1,]32 [2

Re: [R] sort a 3 dimensional array across third dimension ?

2011-02-18 Thread Joshua Wiley
Dear Jim, This works for your small example. I was not exactly sure what you were sorting on. In my example, I sum all values at each level of the third dimension and sort by that sum. Of course, if there are many levels or the 2 dimensions being summed are quite large, this will be quite compu

[R] sort a 3 dimensional array across third dimension ?

2011-02-18 Thread Maas James Dr (MED)
I'm attempting to sort a 3 dimensional array that looks like this > x , , 1 [,1] [,2] [1,]99 [2,]79 , , 2 [,1] [,2] [1,]65 [2,]46 , , 3 [,1] [,2] [1,]21 [2,]32 Such that it ends up like this > y , , 1 [,1] [,2] [1,]21

Re: [R] sort by column and row names

2011-02-17 Thread Jim Moon
Yes, that is it. Thank you very much, Phil. -Original Message- From: Phil Spector [mailto:spec...@stat.berkeley.edu] Sent: Thursday, February 17, 2011 3:36 PM To: Jim Moon Cc: r-help@r-project.org Subject: Re: [R] sort by column and row names Jim - I believe dat[order(rownames

Re: [R] sort by column and row names

2011-02-17 Thread Phil Spector
Jim - I believe dat[order(rownames(dat)),order(colnames(dat))] is what you are looking for. - Phil Spector Statistical Computing Facility Department of Statistics

[R] sort by column and row names

2011-02-17 Thread Jim Moon
Hello, All, How can one sort on column and row names. For example: How can this X1 X3 X2 X1 1 0 0 X3 0 1 0 X2 0 0 1 become this? X1 X2 X3 X1 1 0 0 X2 0 1 0 X3 0 0 1 Thank you for your time! Jim [[alternative H

Re: [R] sort file names in numerical order

2010-07-18 Thread David Winsemius
Another option: require(gtools) ?mixedsort > mixedsort(fileNames) [1] "A1" "A2" "A10" "B1" "B2" "B10" -- David On Jul 18, 2010, at 5:16 AM, Duncan Mackay wrote: Hi Yes it is possible- one way is: fileNames[order(sprintf("%02s", sub("[[:upper:]]","", fileNames)))] [1] "A1" "B1" "A

Re: [R] sort file names in numerical order

2010-07-18 Thread Duncan Mackay
Hi Yes it is possible- one way is: fileNames[order(sprintf("%02s", sub("[[:upper:]]","", fileNames)))] [1] "A1" "B1" "A2" "B2" "A10" "B10" Regards Duncan Duncan Mackay Department of Agronomy and Soil Science University of New England ARMIDALE NSW 2351 Email home: mac...@northnet.com.au A

Re: [R] sort file names in numerical order

2010-07-17 Thread Michael Hannon
> I get some file names by list.files(). > These names are in alphabetical order. > I want to change it to logical numeric order. > Example: > > fileNames <- c("A10", "A1", "A2", "B1", "B2", "B10") > > sort(fileNames) > [1] "A1" "A10" "A2" "B1" "B10" "B2" > I want to have: > "A1" "A2" "A1

Re: [R] sort file names in numerical order

2010-07-17 Thread Sebastian Gibb
thanks a lot, it works. you wrote: > library(gtools) > ?mixedorder > > --- On Sat, 7/17/10, Sebastian Gibb wrote: > > From: Sebastian Gibb > > Subject: [R] sort file names in numerical order > > To: r-help@r-project.org > > Received: Saturday, July 17, 201

Re: [R] sort file names in numerical order

2010-07-17 Thread Gabor Grothendieck
On Sat, Jul 17, 2010 at 4:31 AM, Sebastian Gibb wrote: > Hello, > > I get some file names by list.files(). > These names are in alphabetical order. > I want to change it to logical numeric order. > Example: >> fileNames <- c("A10", "A1", "A2", "B1", "B2", "B10") >> sort(fileNames) > [1] "A1"  "A10

Re: [R] sort file names in numerical order

2010-07-17 Thread John Kane
library(gtools) ?mixedorder --- On Sat, 7/17/10, Sebastian Gibb wrote: > From: Sebastian Gibb > Subject: [R] sort file names in numerical order > To: r-help@r-project.org > Received: Saturday, July 17, 2010, 4:31 AM > Hello, > > I get some file names by list.files().

[R] sort file names in numerical order

2010-07-17 Thread Sebastian Gibb
Hello, I get some file names by list.files(). These names are in alphabetical order. I want to change it to logical numeric order. Example: > fileNames <- c("A10", "A1", "A2", "B1", "B2", "B10") > sort(fileNames) [1] "A1" "A10" "A2" "B1" "B10" "B2" I want to have: "A1" "A2" "A10" "B1" "B2" "B1

Re: [R] sort a data.frame

2010-05-21 Thread Kevin Wright
rame >>> dd <- data.frame(b = c("chr2", "chr1", "chrY", "chr13", "chrX"), >>>     x = c("A", "D", "A", "C", "C"), y = c(8, 3, 9, 9,7), >>>      z = c(1, 1, 1, 2, 8)

Re: [R] sort a data.frame

2010-05-21 Thread David Winsemius
he column b consists of not only number but also one letter after "chr", for example chrX, chrY. I want to put them after number but in the order of ASCII. i.e. chr1--- On *Thu, 20/5/10, Jorge Ivan Velez * wrote: From: Jorge Ivan Velez Subject: Re: [R] sort a data.frame To: &quo

Re: [R] sort a data.frame

2010-05-20 Thread Yuan Jian
it's a excellent solution. I am sorry I missed something in my question. the column b consists of not only number but also one letter after "chr", for example chrX, chrY. I want to put them after number but in the order of ASCII. i.e. chr1 wrote: From: Jorge Ivan Velez Subject:

  1   2   3   >