RE: [R] Sorting problem

2004-12-24 Thread Ted Harding
On 24-Dec-04 Gabor Grothendieck wrote:
>> From: Gabor Grothendieck <[EMAIL PROTECTED]>
>> > > From: <[EMAIL PROTECTED]>
>> > > On 24-Dec-04 Gabor Grothendieck wrote:
>> > > > Actually they are shown in order of the levels of the factor.
>> > > > e.g. to show them in reverse order:
>> > > > 
>> > > > attach(InsectSprays)
>> > > > spray<-factor(as.character(spray),level=rev(levels(spray)))
>> > > > boxplot(count ~ spray)
>> > > 
>> > > Applying boxplot to data constructed as follows:
>> > > 
>> > > X<-list(C=rnorm(10),B=rnorm(20),A=rnorm(30))
>> > > boxplot(X)
>> > > 
>> > > gives the plots in the order "C", "B", "A", so here they indeed
>> > > come out in the order of the data.
>> > > 
>> > > But suppose I had wanted them in the order "B", "A", "C", say.
>> > > How would Gabor's suggestion (or similar) be applied to this case?
>> > 
>> > boxplot(X[c("B","C","A")])
>> > 
>> 
>> It occurred to me that maybe your question was not how to reorder
>> them if they are in list form but how to convert the list form
>> to the formula form. If that was it then:

Yes, I was interested in how to relate the two forms.

>> Xu <- unlist(X)
>> g <- factor(rep(names(X), sapply(X, length)))
>> # add levels= arg to reorder
>> boxplot(Xu ~ g)

And thanks for this manoeuvre! But ...

> or even shorter:
> 
> boxplot(values ~ ind, stack(X))

... Wow!! I always admire neat footwork, but, Gabor, how many
feet have you got? This is like watching the 3-card trick!

Happy Christmas!
Ted.



E-Mail: (Ted Harding) <[EMAIL PROTECTED]>
Fax-to-email: +44 (0)870 094 0861  [NB: New number!]
Date: 24-Dec-04   Time: 18:16:05
-- XFMail --

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


RE: [R] Sorting problem

2004-12-24 Thread Gabor Grothendieck

From:   Gabor Grothendieck <[EMAIL PROTECTED]>
> 
> [sorry. I had some email problems on my last one. here it
> is again.]
> 
> From: Gabor Grothendieck <[EMAIL PROTECTED]>
> > 
> > > From: <[EMAIL PROTECTED]>
> > > 
> > > On 24-Dec-04 Gabor Grothendieck wrote:
> > > > 
> > > > From: Paul JH Drake <[EMAIL PROTECTED]>
> > > >> 
> > > >> When I plot data as a boxplot, the boxes appear on the plot in
> > > >> alphabetical order (of group) rather than the order in which they
> > > >> appear
> > > >> in the data. So far, the only thing I can do to fix this is to prefix
> > > >> the group labels with a,b,c...etc to trick R into plotting them in the
> > > >> right order.
> > > >> 
> > > >> Can sorting be turned off?
> > > >> How should I address this sensibly?
> > > > 
> > > > Actually they are shown in order of the levels of the factor.
> > > > e.g. to show them in reverse order:
> > > > 
> > > > attach(InsectSprays)
> > > > spray <- factor( as.character(spray), level = rev(levels(spray)) )
> > > > boxplot(count ~ spray)
> > > 
> > > Applying boxplot to data constructed as follows:
> > > 
> > > X<-list(C=rnorm(10),B=rnorm(20),A=rnorm(30))
> > > boxplot(X)
> > > 
> > > gives the plots in the order "C", "B", "A", so here they indeed
> > > come out in the order of the data.
> > > 
> > > But suppose I had wanted them in the order "B", "A", "C", say.
> > > How would Gabor's suggestion (or similar) be applied to this case?
> > 
> > boxplot(X[c("B","C","A")])
> > 
> 
> It occurred to me that maybe your question was not how to reorder
> them if they are in list form but how to convert the list form
> to the formula form. If that was it then:
> 
> Xu <- unlist(X)
> g <- factor(rep(names(X), sapply(X, length))) # add levels= arg to reorder
> boxplot(Xu ~ g)

or even shorter:

boxplot(values ~ ind, stack(X))

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


RE: [R] Sorting problem

2004-12-24 Thread Gabor Grothendieck

[sorry. I had some email problems on my last one.  here it
is again.]

From:   Gabor Grothendieck <[EMAIL PROTECTED]>
> 
> > From: <[EMAIL PROTECTED]>
> > 
> > On 24-Dec-04 Gabor Grothendieck wrote:
> > > 
> > > From: Paul JH Drake <[EMAIL PROTECTED]>
> > >> 
> > >> When I plot data as a boxplot, the boxes appear on the plot in
> > >> alphabetical order (of group) rather than the order in which they
> > >> appear
> > >> in the data. So far, the only thing I can do to fix this is to prefix
> > >> the group labels with a,b,c...etc to trick R into plotting them in the
> > >> right order.
> > >> 
> > >> Can sorting be turned off?
> > >> How should I address this sensibly?
> > > 
> > > Actually they are shown in order of the levels of the factor.
> > > e.g. to show them in reverse order:
> > > 
> > > attach(InsectSprays)
> > > spray <- factor( as.character(spray), level = rev(levels(spray)) )
> > > boxplot(count ~ spray)
> > 
> > Applying boxplot to data constructed as follows:
> > 
> > X<-list(C=rnorm(10),B=rnorm(20),A=rnorm(30))
> > boxplot(X)
> > 
> > gives the plots in the order "C", "B", "A", so here they indeed
> > come out in the order of the data.
> > 
> > But suppose I had wanted them in the order "B", "A", "C", say.
> > How would Gabor's suggestion (or similar) be applied to this case?
> 
> boxplot(X[c("B","C","A")])
> 

It occurred to me that maybe your question was not how to reorder
them if they are in list form but how to convert the list form
to the formula form.  If that was it then:

Xu <- unlist(X)
g <- factor(rep(names(X), sapply(X, length)))  # add levels= arg to reorder
boxplot(Xu ~ g)

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


RE: [R] Sorting problem

2004-12-24 Thread Gabor Grothendieck

>  page took 6.48 seconds  • home | my page | my email 
>   .   
>  
>  
>  
>  
> 
>  email 
>  
>  
>  
> 
> Mail Addresses Calendar Notepad [EMAIL PROTECTED] sign out 
> << Hide Folders Check Messages Compose Message POP Accounts | Mail 
> Preferences | Help 
>  
>  
> Folders 
> Inbox 
> Drafts 
> Sent 
> Trash (Empty) 
> Bulk Mail (Empty) 
>  
>  
>  
> My Folders edit 
> R 
> Rcom 
> Rtmp 
> Saved 
> this 
> Tx 
> wcd 
> zoo 
>  
>  
>  
> Spam Tools info 
>Spam Filter Level:
>  OffLowMediumMedium-highHigh 
> My Block List 
> Image Filter 
> Custom Filters 
>  
>  
>  
>  
>  
>  
> Now Live: 
> 
>  125MB Free Storage Upgrade  
>  
>  
>  
> 
>  Send/Receive 10MB emails!  
>  
>  
>  
> 
> < Prev Next >   Back to Inbox Print View  Full Header 
>  
> As AttachmentAs Inline Text Move to Folder- Folders 
> --InboxDraftsSentTrashBulk Mail My Folders 
> RRcomRtmpSavedthisTxwcdzoo
>  
>  
> 
>  Message is not flagged. [ Flag for Follow Up ] 
> 
> From:   Gabor Grothendieck <[EMAIL PROTECTED]>
> 
> > From: <[EMAIL PROTECTED]>
> > 
> > On 24-Dec-04 Gabor Grothendieck wrote:
> > > 
> > > From: Paul JH Drake <[EMAIL PROTECTED]>
> > >> 
> > >> When I plot data as a boxplot, the boxes appear on the plot in
> > >> alphabetical order (of group) rather than the order in which they
> > >> appear
> > >> in the data. So far, the only thing I can do to fix this is to prefix
> > >> the group labels with a,b,c...etc to trick R into plotting them in the
> > >> right order.
> > >> 
> > >> Can sorting be turned off?
> > >> How should I address this sensibly?
> > > 
> > > Actually they are shown in order of the levels of the factor.
> > > e.g. to show them in reverse order:
> > > 
> > > attach(InsectSprays)
> > > spray <- factor( as.character(spray), level = rev(levels(spray)) )
> > > boxplot(count ~ spray)
> > 
> > Applying boxplot to data constructed as follows:
> > 
> > X<-list(C=rnorm(10),B=rnorm(20),A=rnorm(30))
> > boxplot(X)
> > 
> > gives the plots in the order "C", "B", "A", so here they indeed
> > come out in the order of the data.
> > 
> > But suppose I had wanted them in the order "B", "A", "C", say.
> > How would Gabor's suggestion (or similar) be applied to this case?
> 
> boxplot(X[c("B","C","A")])
> 

It occurred to me that maybe your question was not how to reorder
them if they are in list form but how to convert the list form
to the formula form.  If that was it then:

Xu <- unlist(X)
g <- factor(rep(names(X), sapply(X, length)))  
boxplot(Xu ~ g)

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] how to ignore t.test error message

2004-12-24 Thread Uwe Ligges
burak kutlu wrote:
Hello,
I was wondering if there is a way to ignore the error
message you get when some of the data means you
compare are constant in some lines of your data frame.
What does the error message say exactly?
Do you have an example?
Even with the degenerated case
  t.test(c(0, 0), c(0, 0))
I don't get any error message.

I'd like to go ahead with t.test 
See ?try
and get the calculated p-values anyway in such a case.
And what is the p-value in such a case?
I guess I haven't understood the problem correctly, so please be more 
specific!

Uwe Ligges

Thanks
-burak
__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] searching Jonathan Baron's R Site - revised function

2004-12-24 Thread Jonathan Baron
Documentation coming soon.
--
# Written by Andy Liaw and modified by Jonathan Baron 12/24/2004.
RSiteSearch <- function(string,
restrict=c("Rhelp02a","Rhelp01","functions","docs"),
format="normal", sortby="score", matchesPerPage=20) {
string <- paste("http://finzi.psych.upenn.edu/cgi-bin/namazu.cgi?query=";,
gsub(" ", "+", string), sep="")
mpp <- paste("max=", matchesPerPage, sep="")

format <- charmatch(format, c("normal", "short"))
if (format == 0) stop("format must be either normal or short")
format <- paste("result=", switch(format, "normal", "short"), sep="")

sortby <- charmatch(sortby, c("score", "date:late", "date:early",
  "field:subject:ascending", 
"field:subject:decending",
  "field:from:ascending", 
"field:from:decending",
  "field:size:ascending", 
"field:size:decending",
  "field:uri:ascending", 
"field:uri:decending",))
if (sortby == 0) stop("wrong sortby specified")
sortby <- paste("sort=",
switch(sortby, "score", "date:late", "date:early",
  "field:subject:ascending", 
"field:subject:decending",
  "field:from:ascending", 
"field:from:decending",
  "field:size:ascending", 
"field:size:decending",
  "field:uri:ascending", "field:uri:decending"),
sep="")

res <- ""
if ("Rhelp02a" %in% restrict) res <- "idxname=Rhelp02a"
if ("Rhelp01" %in% restrict) res <- paste(res,"idxname=Rhelp01",sep="&")
if ("docs" %in% restrict) res <- paste(res,"idxname=docs",sep="&")
if ("functions" %in% restrict) res <- paste(res,"idxname=functions",sep="&")
if (res=="") {print("Using defaults: Rhelp 2002-; functions; docs.")
  res <- paste("idxname=Rhelp02a&idxname=functions&idxname=docs",sep="")}
res <- sub("^&+","",res)

qstring <- paste(string, mpp, format, sortby, res, sep="&")
browseURL(qstring)
invisible(qstring)
}

-- 
Jonathan Baron, Professor of Psychology, University of Pennsylvania
Home page: http://www.sas.upenn.edu/~baron

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] Sorting problem

2004-12-24 Thread Paul JH Drake
Hi
Sorry if my post wasn't clear.

R version: 2.0.0
OS: SuSE 9.1
Pentium IV laptop

I have been creating boxplots as follows:
boxplot(gene~Group) [additional options left out for simplicity]

and the problem was that the boxplots were plotted in alphabetical
order, rather than the order in which I wanted them to be plotted.

Thanks for your suggestions - now that I know a little more about
factors, I have been able to arrange the order of the levels of the
factor "Group" and all is well!

Thanks for your patience and help

Paul

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


RE: [R] Sorting problem

2004-12-24 Thread Gabor Grothendieck

> From:   <[EMAIL PROTECTED]>
>  
> On 24-Dec-04 Gabor Grothendieck wrote:
> > 
> > From: Paul JH Drake <[EMAIL PROTECTED]>
> >> 
> >> When I plot data as a boxplot, the boxes appear on the plot in
> >> alphabetical order (of group) rather than the order in which they
> >> appear
> >> in the data. So far, the only thing I can do to fix this is to prefix
> >> the group labels with a,b,c...etc to trick R into plotting them in the
> >> right order.
> >> 
> >> Can sorting be turned off?
> >> How should I address this sensibly?
> > 
> > Actually they are shown in order of the levels of the factor.
> > e.g. to show them in reverse order:
> > 
> > attach(InsectSprays)
> > spray <- factor( as.character(spray), level = rev(levels(spray)) )
> > boxplot(count ~ spray)
> 
> Applying boxplot to data constructed as follows:
> 
> X<-list(C=rnorm(10),B=rnorm(20),A=rnorm(30))
> boxplot(X)
> 
> gives the plots in the order "C", "B", "A", so here they indeed
> come out in the order of the data.
> 
> But suppose I had wanted them in the order "B", "A", "C", say.
> How would Gabor's suggestion (or similar) be applied to this case?

boxplot(X[c("B","C","A")])

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


RE: [R] Sorting problem

2004-12-24 Thread Prof Brian Ripley
On Fri, 24 Dec 2004 [EMAIL PROTECTED] wrote:
On 24-Dec-04 Gabor Grothendieck wrote:
From:   Paul JH Drake <[EMAIL PROTECTED]>
When I plot data as a boxplot, the boxes appear on the plot in
alphabetical order (of group) rather than the order in which they
appear
in the data. So far, the only thing I can do to fix this is to prefix
the group labels with a,b,c...etc to trick R into plotting them in the
right order.
Can sorting be turned off?
How should I address this sensibly?
Actually they are shown in order of the levels of the factor.
That's making lots of unsubstantiated assumptions, including that the 
formula interface to boxplot() was used: we do not even know that 
boxplot() was used (rather than plot.factor or bwplot or ...).

e.g. to show them in reverse order:
attach(InsectSprays)
spray <- factor( as.character(spray), level = rev(levels(spray)) )
boxplot(count ~ spray)
Applying boxplot to data constructed as follows:
 X<-list(C=rnorm(10),B=rnorm(20),A=rnorm(30))
 boxplot(X)
gives the plots in the order "C", "B", "A", so here they indeed
come out in the order of the data.
But suppose I had wanted them in the order "B", "A", "C", say.
How would Gabor's suggestion (or similar) be applied to this case?
(OK I'm being thick, maybe; but I can't see how to relate the
one to the other!)
They are not related.  You need to reorder the elements in your list:
boxplot(X[c("B", "A", "C")])
The help page for boxplot in R-devel explains both approaches.
--
Brian D. Ripley,  [EMAIL PROTECTED]
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford, Tel:  +44 1865 272861 (self)
1 South Parks Road, +44 1865 272866 (PA)
Oxford OX1 3TG, UKFax:  +44 1865 272595
__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


RE: [R] Sorting problem

2004-12-24 Thread Ted Harding
On 24-Dec-04 Gabor Grothendieck wrote:
> 
> From:   Paul JH Drake <[EMAIL PROTECTED]>
>> 
>> When I plot data as a boxplot, the boxes appear on the plot in
>> alphabetical order (of group) rather than the order in which they
>> appear
>> in the data. So far, the only thing I can do to fix this is to prefix
>> the group labels with a,b,c...etc to trick R into plotting them in the
>> right order.
>> 
>> Can sorting be turned off?
>> How should I address this sensibly?
> 
> Actually they are shown in order of the levels of the factor.
> e.g. to show them in reverse order:
> 
> attach(InsectSprays)
> spray <- factor( as.character(spray), level = rev(levels(spray)) )
> boxplot(count ~ spray)

Applying boxplot to data constructed as follows:

  X<-list(C=rnorm(10),B=rnorm(20),A=rnorm(30))
  boxplot(X)

gives the plots in the order "C", "B", "A", so here they indeed
come out in the order of the data.

But suppose I had wanted them in the order "B", "A", "C", say.
How would Gabor's suggestion (or similar) be applied to this case?
 
(OK I'm being thick, maybe; but I can't see how to relate the
one to the other!)

Ted.

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] Sorting problem

2004-12-24 Thread Prof Brian Ripley
On Fri, 24 Dec 2004, Paul JH Drake wrote:
I'm using R 2.0 in SuSE 9.2.
There is no such version, BTW: please see the posting guide for hints on 
supplying the sort of information we need (and an example would have 
helped a lot here).

When I plot data as a boxplot, the boxes appear on the plot in
alphabetical order (of group) rather than the order in which they appear
in the data.
I'm guessing you used the formula interface to boxplot(): if so they 
appear in the order of the levels of the factor.  Otherwise they appear in 
the order the groups are supplied to boxplot().

So far, the only thing I can do to fix this is to prefix the group 
labels with a,b,c...etc to trick R into plotting them in the right 
order.

Can sorting be turned off?
No, as it is not turned on!
How should I address this sensibly?
I need to be guessing, again!  Create your group as a factor with the 
levels in the order you want.  You don't tell us how you created it, but 
see ?factor.  In particular, if you did not supply a factor but something 
which was coerced to a factor, supply a factor.

--
Brian D. Ripley,  [EMAIL PROTECTED]
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford, Tel:  +44 1865 272861 (self)
1 South Parks Road, +44 1865 272866 (PA)
Oxford OX1 3TG, UKFax:  +44 1865 272595
__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


RE: [R] Sorting problem

2004-12-24 Thread Gabor Grothendieck

From:   Paul JH Drake <[EMAIL PROTECTED]>
> 
> When I plot data as a boxplot, the boxes appear on the plot in
> alphabetical order (of group) rather than the order in which they appear
> in the data. So far, the only thing I can do to fix this is to prefix
> the group labels with a,b,c...etc to trick R into plotting them in the
> right order.
> 
> Can sorting be turned off?
> How should I address this sensibly?

Actually they are shown in order of the levels of the factor.
e.g. to show them in reverse order:

attach(InsectSprays)
spray <- factor( as.character(spray), level = rev(levels(spray)) )
boxplot(count ~ spray)

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


[R] Sorting problem

2004-12-24 Thread Paul JH Drake
Hi
I'm using R 2.0 in SuSE 9.2.

When I plot data as a boxplot, the boxes appear on the plot in
alphabetical order (of group) rather than the order in which they appear
in the data. So far, the only thing I can do to fix this is to prefix
the group labels with a,b,c...etc to trick R into plotting them in the
right order.

Can sorting be turned off?
How should I address this sensibly?

Thanks in advance

Paul

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html