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)
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$
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
> 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
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
> 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
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
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
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)
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
-
>> 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:
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.
>
>
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
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
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
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
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
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
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
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
>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
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
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
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
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...
___
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
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
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
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/
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
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
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
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
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
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"
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
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 -
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
.
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
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:
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
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
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"
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
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,
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
;
[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
&
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
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,]
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 "
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
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]
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]
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
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
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
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
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
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
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
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)) {
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
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
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
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
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
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
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
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
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
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"
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
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
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
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
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
? 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
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
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 >
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
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
>
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
,])
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 ?
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
>,
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
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
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
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
Jim -
I believe
dat[order(rownames(dat)),order(colnames(dat))]
is what you are looking for.
- Phil Spector
Statistical Computing Facility
Department of Statistics
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
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
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
> 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
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
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
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().
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
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)
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
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 - 100 of 204 matches
Mail list logo