Thank you very much Jim.

jim holtman a écrit :
> You can reorder like this:
>
> y <- unique(do.call(paste,c(mydata[,1:2],sep = ":")))
> ordered.mydata <- mydata.split[y]
>
> On Nov 26, 2007 3:08 PM, Sébastien <pomchip@free.fr> wrote:
>   
>> One additionnal question about a problem that I just noticed in my script:
>> the list created by my split function is sorted in the increasing order and
>> not in the current order of the elements of the do.call argument (see the
>> results of the two last lines of the following script). I was unsuccesful in
>> tweaking my split function to have a proper order...
>> If there is no way to do that, I guess it comes down to a very basic
>> question: how can I reorder a list ?
>>
>> ####
>> how can I reorder the list 'mydata.split' according to
>>
>> a<-rep(1.5:10.5,each=2)
>> b<-rep(21:30,each=2)
>> cd<-101:120
>> mydata<-data.frame(a,b,cd)
>>
>> mydata.split <- split(mydata,do.call(paste,c(mydata[,1:2],sep =
>> ":")),drop=TRUE)
>> names(mydata.split)
>> unique(do.call(paste,c(mydata[,1:2],sep = ":")))
>>
>> ####
>>
>> Sebastien
>>
>> Gabor Grothendieck a écrit :
>> Try this using the BOD data frame that comes with R or
>> try using interaction
>> in place of paste:
>>
>> split(BOD, do.call(paste, c(BOD, sep = ":")),
>> drop=TRUE)
>>
>>
>> On Nov 25, 2007 10:23 AM, <pomchip@free.fr> wrote:
>>
>> Thanks Jim and Herinque for you reply.
>>
>> The substitution you are both
>> proposing works fine, except when a or b contains
>> decimal numbers (which is
>> mostly my case in a real dataset). In this case, there
>> is no distinction
>> between the decimal point and the one introduced by the split
>> function.
>> If
>> the split function cannot be customized, then I guess I have to
>> first
>> substitute the decimal point in my dataset by e.g. a * sign and change
>> it back
>> to a . when the split is done...
>>
>> Sebastien
>>
>> jim holtman a écrit :
>>
>>
>> Here is one way:
>>
>>
>> a<-1:10
>> b<-21:30
>> mydata<-data.frame(a,b)
>> mydata.split<-split(mydata,(mydata[,1:2]),drop=TRUE)
>> x
>> <- mydata.split
>> # customize the names
>> names(x) <- sapply(strsplit(names(x),
>> "\\."), paste, collapse="-my
>>
>> character-")
>>
>>
>> x
>>
>> $`1-my character-21`
>>  a b
>> 1 1 21
>>
>> $`2-my character-22`
>>  a b
>> 2 2 22
>>
>> $`3-my
>> character-23`
>>  a b
>> 3 3 23
>> ...........
>>
>> On Nov 24, 2007 6:15 PM,
>> <pomchip@free.fr> wrote:
>>
>> Dear R-users,
>>
>> The following code splits a very simple dataframe into a
>> list, each element
>>
>> of
>>
>>
>> the list being one line of the dataframe. You will see that the split
>>
>> function
>>
>>
>> names each element of the list by using uses the content of a and b and
>>
>> merging
>>
>>
>> them with a "." character. Is there a way to customize this
>> character?
>>
>> a<-1:10
>> b<-21:30
>> mydata<-data.frame(a,b)
>> mydata.split<-split(mydata,(mydata[,1:2]),drop=TRUE)
>> mydata.split
>>
>> Thanks
>> in advance for your
>> help.
>>
>> Sebastien
>>
>> ______________________________________________
>> 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, self-contained, reproducible code.
>>
>>
>>
>>
>> ______________________________________________
>> 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, self-contained, reproducible code.
>>
>>
>>
>>
>>
>>     
>
>
>
>   

	[[alternative HTML version deleted]]

