[R] how to change the position of xlab in truehist?

2010-04-16 Thread Hua Li
Hi,

I'm wondering how can I change the position of xlab in truehist. For example, 
the following code creats a histogram with 4 bins for my discrete data. I want 
each bin to be labelled as 0, 1, 2, or 3 in the middle, so that it's clear each 
bin corresponds to each of the discrete case. 

I was thinking of first delete xlab and then add marks myself, but it doesn't 
look like it's working. The old label can not be removed by setting xlab= or 
xlab = NULL.

Thanks for your help!

Hua

#
x = c(rep(0,10),rep(1,100),rep(2,50), rep(3,30))
library(MASS)
truehist(x,nbins=4)

truehist(x,nbins=4,xlab=)

__
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.


Re: [R] how to change the position of xlab in truehist?

2010-04-18 Thread Hua Li
Thanks, Peter. It works!

Hua

--- On Fri, 4/16/10, Peter Ehlers ehl...@ucalgary.ca wrote:

 From: Peter Ehlers ehl...@ucalgary.ca
 Subject: Re: [R] how to change the position of xlab in truehist?
 To: Hua Li huali...@yahoo.com
 Cc: r-help@r-project.org
 Date: Friday, April 16, 2010, 6:23 PM
 On 2010-04-16 16:00, Hua Li wrote:
  Hi,
 
  I'm wondering how can I change the position of xlab in
 truehist. For example, the following code creats a histogram
 with 4 bins for my discrete data. I want each bin to be
 labelled as 0, 1, 2, or 3 in the middle, so that it's clear
 each bin corresponds to each of the discrete case.
 
  I was thinking of first delete xlab and then add marks
 myself, but it doesn't look like it's working. The old label
 can not be removed by setting xlab= or xlab = NULL.
 
  Thanks for your help!
 
  Hua
 
  #
  x = c(rep(0,10),rep(1,100),rep(2,50), rep(3,30))
  library(MASS)
  truehist(x,nbins=4)
 
  truehist(x,nbins=4,xlab=)
 
 I think you misunderstand 'xlab'; it's the label for the
 x-axis,
 i.e. the 'x' that is produced by your first truehist()
 call.
 You want to change the value labels on the axis. You're on
 the
 right track by leaving that off and then adding your
 preferred
 labels at your preferred locations:
 
   truehist(x, nbins = 4, xaxt = n)  ## see xaxt
 under ?par
   axis(1, at = 0:3 + 0.5, labels = 0:3)
 
 I usually add
 
   box(bty = l)
 
 -- 
 Peter Ehlers
 University of Calgary
 




__
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 on drawing a tree with ape?

2007-11-11 Thread Hua Li
Dear all,

I'm using the ape package in R and want to draw a
phylogenetic tree with not only the tip labels but
also some labels for the edges. e.g. Mark the edge AB
as m in the tree ABC.  

Couldn't find a way to do that. Can someone help?

Thanks,

Hua

__
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.


Re: [R] help on drawing a tree with ape?

2007-11-12 Thread Hua Li

Thank you very much for the help, Ben!

As a follow up, is there a way to specify the labels,
through the way the text is written, rather than
reading the edge positions from the graph? For
example, 

mytree =
((A:51.78,(C:24.6,D:24.6):27.18):40.06,B:91.84):0.0;
plot(read.tree(text = mytree))
edgelabels(c(a-b,b,b-d,d,d,a))

would give the graph I want. You may notice that if
set a = 91.84; b= 51.78; d= 24.6, the labels I put on
each edge is the corresponding lengths in variable
form.  The way I do it right now need me to first draw
the tree and then manually set the labels, and I
suppose there should be an easier way to get them by
reading the way the tree is written
(((A:51.78,(C:24.6,D:24.6):27.18):40.06,B:91.84):0.0;)?


Sorry for my low level questions. Just started using
ape and research on phylogenetic trees.

Best wishes,

Hua





--- Ben Bolker [EMAIL PROTECTED] wrote:

 
 
 
 Hua Li wrote:
  
  Dear Simon and everyone,
  
  Thanks for response. 
  
  Specifically, I have a tree with species A, B, C
 and
  can be written as
  ((A:45.15,C:45.15):46.19,B:91.34):0.0; . If I
 use
  the R command
  mytreeABC
  
  [1] ((A:45.15,C:45.15):46.19,B:91.34):0.0;
  
  plot(read.tree(text = mytreeABC))
  
  --- Simon Blomberg [EMAIL PROTECTED] wrote:
  
  ?edgelabels
  
  
 
Did you look at the examples in the file
 suggested by Simon?
 Unfortunately, the PS file but not the JPG came
 through in the
 version I read.
 
   It seems to me you may want _node_ labels rather
 than _edge_ labels?See below ...
 
 mytreeABC = ((A:45.15,C:45.15):46.19,B:91.34):0.0;
 t1 = read.tree(text=mytreeABC)
 library(ape)
 plot(t1)
 edgelabels(1:4)
 nodelabels(c(a,b))
 
 -- 
 View this message in context:

http://www.nabble.com/help-on-drawing-a-tree-with-%22ape%22--tf4789546.html#a13711995
 Sent from the R help mailing list archive at
 Nabble.com.
 
 __
 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.
 



  

Never miss a thing.  Make Yahoo your home page.

__
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] the title is too long for a graph

2008-06-10 Thread Hua Li
Hi All,

I have a problem of putting long titles on a graph:

for example,

x= seq(1:100)
y=seq(1:100)
plot(x,y,main=p=0.05:A-B=3,C-D=10,D-E=100,A-F=2,AFR-E=3,ACE-D=1,ADEF-M=0,AED-E=10,DE-F=3,AB-J=4,AC-J=10,ED-F=1,ED-B=4,AF-B=10,CD-S=10,AM-C=4)

R seems not able to print the whole title. The title content might be changing 
and thus I don't know how long it is beforehand. Is there a way to measure the 
length and then put the title into different lines accordingly?

Thanks!

Hua

__
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.


Re: [R] the title is too long for a graph

2008-06-11 Thread Hua Li
Thank you all! The answers are very helpful!

Best regards,

Hua


--- On Wed, 6/11/08, Prof Brian Ripley [EMAIL PROTECTED] wrote:

 
  Hua Li wrote:
  Hi All,
  
  I have a problem of putting long titles on a
 graph:
  
  for example,
  
  x= seq(1:100)
  y=seq(1:100)
 
 plot(x,y,main=p=0.05:A-B=3,C-D=10,D-E=100,A-F=2,AFR-E=3,ACE-D=1,ADEF-M=0,AED-E=10,DE-F=3,AB-J=4,AC-J=10,ED-F=1,ED-B=4,AF-B=10,CD-S=10,AM-C=4)
  
  R seems not able to print the whole title. The

__
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] numbers as part of long character

2008-06-12 Thread Hua Li
Hi,

I'm looking for some way to pick up the numbers which are contained and buried 
in a long character. 

For example,

outtree.new=(((B:1204.25,E:1204.25):7581.11,F:8785.36):8353.85,C:17139.21);

num.char = 
unlist(strsplit(unlist(strsplit(unlist(strsplit(unlist(strsplit(unlist(strsplit(outtree.new,),fixed=TRUE)),(,fixed=TRUE)),:,fixed=TRUE)),,,fixed=TRUE)),;,fixed=TRUE))

num.vec=as.numeric(num.char[1:(length(num.char)-1)])

num.char
#  B1204.25  E1204.25  7581.11  F8785.36  
8353.85  C17139.21  

num.vec
# NA  1204.25   NA  1204.25  7581.11   NA  8785.36  8353.85   NA 
17139.21

would help me get the numbers such as 1204.25, 7581.11, etc, but with a warning 
message which reads:
Warning message:
NAs introduced by coercion 

Is there a way to get around this? Thanks!

Hua

__
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.


Re: [R] numbers as part of long character

2008-06-12 Thread Hua Li
Thanks, Marc and Haris! 

I didn't know the values of the numbers beforehand, so the scan method won't 
work, but [^+-\\d.]+ will do! 

And Haris, I didn't intend to keep the information of which number is B, which 
is C etc when asking the question, as I had a tedious way to do it (use 
strspilt and unlist over and over again, after I get the number). But if you 
have a easier way to do it, I'd like to know!
 
Hua


--- On Thu, 6/12/08, Charilaos Skiadas [EMAIL PROTECTED] wrote:

 From: Charilaos Skiadas [EMAIL PROTECTED]
 Subject: Re: [R] numbers as part of long character
 To: [EMAIL PROTECTED]
 Cc: [EMAIL PROTECTED], r-help@r-project.org
 Date: Thursday, June 12, 2008, 6:03 PM
 On Jun 12, 2008, at 5:06 PM, Marc Schwartz wrote:
 
  on 06/12/2008 03:46 PM Hua Li wrote:
  Hi,
  I'm looking for some way to pick up the
 numbers which are  
  contained and buried in a long character. For
 example,
 
 outtree.new=(((B:1204.25,E:1204.25):7581.11,F:8785.36):8353.85,C:
 
  17139.21);
  num.char =
 unlist(strsplit(unlist(strsplit(unlist(strsplit(unlist 
  (strsplit(unlist(strsplit 
 
 (outtree.new,),fixed=TRUE)),(,fixed=TRUE)),:,fixed=TRUE)),,,f
 
  ixed=TRUE)),;,fixed=TRUE))
 
 num.vec=as.numeric(num.char[1:(length(num.char)-1)])
  num.char
  #  B1204.25 
 E1204.25 
 7581.11   
  F8785.36 
 8353.85  C   
 17139.21  num.vec
  # NA  1204.25   NA  1204.25  7581.11   NA 
 8785.36   
  8353.85   NA 17139.21
  would help me get the numbers such as 1204.25,
 7581.11, etc, but  
  with a warning message which reads:
  Warning message:
  NAs introduced by coercion 
  Is there a way to get around this? Thanks!
  Hua
 
  Your code above is overly and needlessly complicated,
 which makes  
  it difficult to debug.
 
  I would take an approach whereby you use gsub() to
 strip non- 
  numeric characters from the input character vector and
 then use scan 
  () to read the remaining numbers:
 
   Vec -
 scan(textConnection(gsub([^0-9\\.]+,
  , outtree.new)))
  Read 6 items
 
   Vec
  [1]  1204.25  1204.25  7581.11  8785.36  8353.85
 17139.21
 
   str(Vec)
   num [1:6] 1204 1204 7581 8785 8354 ...
 
 
  The result of using gsub() above is:
 
   gsub([^0-9\\.]+, 
 , outtree.new)
  [1]  1204.25 1204.25 7581.11 8785.36 8353.85
 17139.21 
 
 
  That gives you a character vector which can then be
 passed to scan 
  () as a textConnection().
 
 Another approach would be to split on sequences of
 non-integers:
 
 as.numeric( strsplit(outtree.new,
 [^\\d.]+, perl=TRUE)[[1]] )
 
 
 Use [^+-\\d.]+ if your numbers might be
 signed. This does assume  
 that dots, +/- occur only as decimal points.
 
 Hua, did you want to keep the information of which number
 is B, which  
 is C etc?
 
  See ?gsub, ?regex, ?textConnection and ?scan for more
 information.
 
  HTH,
 
  Marc Schwartz
 
 
 Haris Skiadas
 Department of Mathematics and Computer Science
 Hanover College

__
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.


Re: [R] numbers as part of long character

2008-06-12 Thread Hua Li
Oh, Sorry, Marc. The scan method does work! 

Hua


--- On Thu, 6/12/08, Charilaos Skiadas [EMAIL PROTECTED] wrote:

 From: Charilaos Skiadas [EMAIL PROTECTED]
 Subject: Re: [R] numbers as part of long character
 To: [EMAIL PROTECTED]
 Cc: [EMAIL PROTECTED], r-help@r-project.org
 Date: Thursday, June 12, 2008, 6:03 PM
 On Jun 12, 2008, at 5:06 PM, Marc Schwartz wrote:
 
  on 06/12/2008 03:46 PM Hua Li wrote:
  Hi,
  I'm looking for some way to pick up the
 numbers which are  
  contained and buried in a long character. For
 example,
 
 outtree.new=(((B:1204.25,E:1204.25):7581.11,F:8785.36):8353.85,C:
 
  17139.21);
  num.char =
 unlist(strsplit(unlist(strsplit(unlist(strsplit(unlist 
  (strsplit(unlist(strsplit 
 
 (outtree.new,),fixed=TRUE)),(,fixed=TRUE)),:,fixed=TRUE)),,,f
 
  ixed=TRUE)),;,fixed=TRUE))
 
 num.vec=as.numeric(num.char[1:(length(num.char)-1)])
  num.char
  #  B1204.25 
 E1204.25 
 7581.11   
  F8785.36 
 8353.85  C   
 17139.21  num.vec
  # NA  1204.25   NA  1204.25  7581.11   NA 
 8785.36   
  8353.85   NA 17139.21
  would help me get the numbers such as 1204.25,
 7581.11, etc, but  
  with a warning message which reads:
  Warning message:
  NAs introduced by coercion 
  Is there a way to get around this? Thanks!
  Hua
 
  Your code above is overly and needlessly complicated,
 which makes  
  it difficult to debug.
 
  I would take an approach whereby you use gsub() to
 strip non- 
  numeric characters from the input character vector and
 then use scan 
  () to read the remaining numbers:
 
   Vec -
 scan(textConnection(gsub([^0-9\\.]+,
  , outtree.new)))
  Read 6 items
 
   Vec
  [1]  1204.25  1204.25  7581.11  8785.36  8353.85
 17139.21
 
   str(Vec)
   num [1:6] 1204 1204 7581 8785 8354 ...
 
 
  The result of using gsub() above is:
 
   gsub([^0-9\\.]+, 
 , outtree.new)
  [1]  1204.25 1204.25 7581.11 8785.36 8353.85
 17139.21 
 
 
  That gives you a character vector which can then be
 passed to scan 
  () as a textConnection().
 
 Another approach would be to split on sequences of
 non-integers:
 
 as.numeric( strsplit(outtree.new,
 [^\\d.]+, perl=TRUE)[[1]] )
 
 
 Use [^+-\\d.]+ if your numbers might be
 signed. This does assume  
 that dots, +/- occur only as decimal points.
 
 Hua, did you want to keep the information of which number
 is B, which  
 is C etc?
 
  See ?gsub, ?regex, ?textConnection and ?scan for more
 information.
 
  HTH,
 
  Marc Schwartz
 
 
 Haris Skiadas
 Department of Mathematics and Computer Science
 Hanover College

__
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] stop unwanted boxes/dialogs in tcl/tk

2008-06-17 Thread Hua Li
Hello,

I have a question about tcl/tk: is there a way to stop more 
messagers/listchoice/etc. that are set up earlier, but are unwanted later?


for example,

require(tcltk)
ttMain - tktoplevel()
tkwm.title(ttMain,Question)

f.fcn - function(){
t1 - modalDialogOK(Elicitation,What's the LOWER bound of 
A1,entryInit=)

t2 - modalDialogOK(Elicitation,What's the LOWER bound of 
A2,entryInit=)

t3 - modalDialogOK(Elicitation,What's the LOWER bound of 
A3,entryInit=)

}

f.fcn()

When run the function, three dialog box would pop up in sequence. If in the 
middle, say, after t2 pop up, I don't want to answer t3, is there a way to 
block t3? Close the t1,t2 boxes(even the question main frame) doesn't stop t3 
coming up, though it gives a lot of error messages.

Thanks!

Hua

__
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] create .exe file with R?

2008-06-19 Thread Hua Li
Dear all,

I'm writing to check with you whether there is a way to create .exe file(or 
something like that) with R. Now working on creating a program to take inputs 
from users (with tcl/tk), I would appreciate any idea to make the program run 
on its own rather than every time having to run my source code in R.

Thanks!

Hua

__
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] print one character on several lines

2008-06-19 Thread Hua Li
Hi All,

I'm wondering how I can print one large/long character on several lines so that 
the output will not overflow a page. Setting fill be TRUE or even numbers does 
not help. An example is below:


ipuFile - file(input.txt, w)  

cat(This is a very long character and I want to print it on several lines. 
This is a very long character and I want to print it on several lines.,fill = 
TRUE,file = ipuFile)   
   
close(ipuFile)

Thanks!

Hua

__
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] ignore warning messages?

2008-07-01 Thread Hua Li
Hi All,

I'm working with R and want to ignore the warning messages given, is there a 
way to stop R from giving out warning messages any more?

an example:

tt = test
as.numeric(tt)

would give me the following message:

[1] NA
Warning message:
NAs introduced by coercion 

I decide to ignore the warning message for now and don't want it to show any 
more, can someone help?

Thanks!


Hua

__
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.


Re: [R] ignore warning messages?

2008-07-06 Thread Hua Li
Thanks a lot, Henrique and Jorge!


--- On Tue, 7/1/08, Jorge Ivan Velez [EMAIL PROTECTED] wrote:

 From: Jorge Ivan Velez [EMAIL PROTECTED]
 Subject: Re: [R] ignore warning messages?
 To: [EMAIL PROTECTED]
 Cc: R-help r-help@r-project.org
 Date: Tuesday, July 1, 2008, 1:12 PM
 Dear Hua,
 
 Try
 
 options(warn=-1)
 tt = test
 as.numeric(tt)
 [1] NA
 
 
 See also ?options for more info.
 
 HTH,
 
 Jorge
 
 
 On Tue, Jul 1, 2008 at 12:11 PM, Hua Li
 [EMAIL PROTECTED] wrote:
 
  Hi All,
 
  I'm working with R and want to ignore the warning
 messages given, is there
  a way to stop R from giving out warning messages any
 more?
 
  an example:
 
  tt = test
  as.numeric(tt)
 
  would give me the following message:
 
  [1] NA
  Warning message:
  NAs introduced by coercion
 
  I decide to ignore the warning message for now and
 don't want it to show
  any more, can someone help?
 
  Thanks!
 
 
  Hua
 
  __
  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.


[R] color with tcl/tk?

2008-07-06 Thread Hua Li
Dear all,

I'm using tcl/tk to create a program to get answers from the user. I'd like a 
way to highlight/emphasize some of the information using colors. It'll be even 
better if I can color part of the messages instead of the whole thing. 

For example, I want to put the word Hello in red:

require(tcltk)
ReturnVal - tkmessageBox(title=Greetings from R TclTk,message=Hello, world! 
Can I print the word 'Hello' in red?,icon=info,type=ok)

using   col=red  doesn't work. 

Could someone give some hint on this! Thanks!

Hua

__
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] position of a specific character

2008-07-14 Thread Hua Li
Hi All,

I'm wondering whether there is a quick way to know the position of a specific 
charcater in a long character:

for example

frg=((D:41.04,I:41.04):45.05,(((E:2.32,((G:0.67,J:0.67):0.44,H:1.11):1.21)

and I would like to know that the 1st, 2nd, 26th, 27th, 28th ... character is 
(, is there a quick way to do that?

Thanks!

Hua

__
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.


Re: [R] position of a specific character

2008-07-14 Thread Hua Li
Well, actually, what I really want is a way to quickly find the fragment that 
contained equal number of ( and ), starting from the end of the character. 
In the case of

frg = =((D:41.04,I:41.04):45.05,(((E:2.32,((G:0.67,J:0.67):0.44,H:1.11):1.21)

that means finding the part: (E:2.32,((G:0.67,J:0.67):0.44,H:1.11):1.21) 
automatically!


Thanks a lot!

Hua



--- On Mon, 7/14/08, Hua Li [EMAIL PROTECTED] wrote:

 From: Hua Li [EMAIL PROTECTED]
 Subject: [R] position of a specific character
 To: R-help r-help@r-project.org
 Date: Monday, July 14, 2008, 6:57 PM
 Hi All,
 
 I'm wondering whether there is a quick way to know the
 position of a specific charcater in a long character:
 
 for example
 
 frg=((D:41.04,I:41.04):45.05,(((E:2.32,((G:0.67,J:0.67):0.44,H:1.11):1.21)
 
 and I would like to know that the 1st, 2nd, 26th, 27th,
 28th ... character is (, is there a quick way
 to do that?
 
 Thanks!
 
 Hua
 
 __
 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.


Re: [R] help on drawing a tree with ape?

2007-11-16 Thread Hua Li
Thanks again, Ben.

Specifically my question should be;

If I know that I'll be using variables to represent
the distances between species:

a = AB
b = AC
d = CD

and I also know my tree can be written as
((A:51.78,(C:24.6,D:24.6):27.18):40.06,B:91.84):0.0;

is there a way to allow me mark the edges without
having to see the tree topology first, so that when I
use edgelabels, the symbols and the order (
c(a-b,b,b-d,d,d,a) ) should be
automatically arranged other than being specified by
me. In other words, I don't want to be the one who
tells R the command
edgelabels(c(a-b,b,b-d,d,d,a)). I'd
rather a way R finds out itself. (for example, after
some calculation, R knows the edgelabes should be the
way specified above other than, say, c(a, b, c,
a-b, a-c, b-c). )

Thank you!

Hua





--- Ben Bolker [EMAIL PROTECTED] wrote:

 -BEGIN PGP SIGNED MESSAGE-
 Hash: SHA1
 
 Hua Li wrote:
  Thank you very much for the help, Ben!
  
  As a follow up, is there a way to specify the
 labels,
  through the way the text is written, rather than
  reading the edge positions from the graph? For
  example, 
  
  mytree =
 

((A:51.78,(C:24.6,D:24.6):27.18):40.06,B:91.84):0.0;
  plot(read.tree(text = mytree))
  edgelabels(c(a-b,b,b-d,d,d,a))
  
  would give the graph I want. You may notice that
 if
  set a = 91.84; b= 51.78; d= 24.6, the labels I put
 on
  each edge is the corresponding lengths in variable
  form.  The way I do it right now need me to first
 draw
  the tree and then manually set the labels, and I
  suppose there should be an easier way to get them
 by
  reading the way the tree is written
 

(((A:51.78,(C:24.6,D:24.6):27.18):40.06,B:91.84):0.0;)?
  
  
  Sorry for my low level questions. Just started
 using
  ape and research on phylogenetic trees.
  
  Best wishes,
  
  Hua
  
 
 How about
 
 
 library(ape)
 mytree =

((A:51.78,(C:24.6,D:24.6):27.18):40.06,B:91.84):0.0;
 t1 = read.tree(text = mytree)
 plot(t1)
 edgelabels(c(a-b,b,b-d,d,d,a))
 str(t1)
 t1$edge.length
 names(t1$edge.length)[c(2,4,6)]=c(b,d,a)
 plot(t1)

edgelabels(c(a-b,b,b-d,d,d,a),adj=c(0.5,1.25))
 with(as.list(t1$edge.length),
 

edgelabels(c(a-b,b,b-d,d,d,a),adj=c(0.5,-0.5),bg=lightblue))
 
 ?
 -BEGIN PGP SIGNATURE-
 Version: GnuPG v1.4.6 (GNU/Linux)
 Comment: Using GnuPG with Mozilla -
 http://enigmail.mozdev.org
 

iD8DBQFHOao+c5UpGjwzenMRAq+xAJ4/FFxTaUXhco2ZSNU4xOHCHWhyQQCfYFV/
 8ymnDHBrtFVDELiZrC2WQ+I=
 =A1e3
 -END PGP SIGNATURE-
 



  

Never miss a thing.  Make Yahoo your home page.

__
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] use save.image inside a function?

2008-01-09 Thread Hua Li
Hi, All 

I'm trying to save the workspace as a Check Point for
possible future come back. The save.image function
works if the whole coding is in a main function:

rm(list=ls())
t = 1
t = t+1
print(paste(before,t))
# [1] before 2
save.image(tt.RData)
 
t = t+1
print(paste(after,t))
# [1] after 3
 
load(tt.RData)
print(paste(check,t))
# [1] check 2

As you can see, the value right before I save the
workspace is restored.

However, if I run the saving inside a function, it
seems that it restores to the vale outside the
function rather than the one before the save command:

rm(list=ls())
test.fcn - function(t=1){
 t = t+1
 print(paste(before,t))
 save.image(tt.RData)

 t = t+1
 print(paste(after,t))
 
 load(tt.RData)
 print(paste(check,t))
 
}
   
t = 1
test.fcn(t=t)
# [1] before 2
# [1] after 3
# [1] check 1

So it restores the value before the program enters the
function (t=1), though what I really want is the value
inside the function(t=2).

Is there anything wrong with the way I use the
save.image function? Or is there other command I can
use to reach my goal?

Thanks a lot!

Hua



  

Never miss a thing.  Make Yahoo your home page.

__
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] disappearing dialog boxes when using tcltk

2009-04-14 Thread Hua Li

Dear all,

I'm trying to use tcltk to build a small
user-interface and couter the problem:

It seems that sometimes the dialog box will be
minimized automatically though I want it to be on top
of the screen all the time. 

For example, when runing the following code, if you
type in a1, a2, a3, etc when being asked for an
integer, the program is supposed to keeping asking you
until you give an integer. The program runs fine, but
the dialog box is not always on top, and it is
annoying having to maximized it every time (the wierd
thing is that sometimes it is Ok, sometimes it is not.
So I don't know the problem.)

Millions of thanks!

Hua

##===
## Add Dialog Box (with only OK button)
##===
modalDialogOK -
function(title,question,entryInit,entryWidth=10)
{
  returnValOnCancel=ID_CANCEL
  dlg - tktoplevel()
  tkwm.deiconify(dlg)
  tkgrab.set(dlg)
  tkfocus(dlg)
  tkwm.title(dlg,title)
  textEntryVarTcl - tclVar(paste(entryInit))
  textEntryWidget -
tkentry(dlg,width=paste(entryWidth),textvariable=textEntryVarTcl)
  tkgrid(tklabel(dlg,text=   ))
  tkgrid(tklabel(dlg,text=question),textEntryWidget)
  tkgrid(tklabel(dlg,text=   ))
  ReturnVal - returnValOnCancel
  onOK - function()
  {
ReturnVal - tclvalue(textEntryVarTcl)
tkgrab.release(dlg)
tkdestroy(dlg)
# tkfocus(dlg)
tkfocus(ttMain)
  }
  OK.but -tkbutton(dlg,text=   OK  
,command=onOK)
  tkgrid(OK.but)
  tkgrid(tklabel(dlg,text=))

  tkfocus(dlg)
  tkbind(dlg, Destroy, function()
{tkgrab.release(dlg);tkfocus(ttMain)})
  tkbind(textEntryWidget, Return, onOK)
  tkwait.window(dlg)

  return(ReturnVal)

}



##===
## main function
##===
require(tcltk)
ttMain - tktoplevel()
tkwm.title(ttMain,Number)
tkdestroy(ttMain)


#initial values are set
numAll = 
speAll = NULL
yrunit = 

ttMain - tktoplevel()
tkfocus(ttMain)
numAll - as.numeric(modalDialogOK(Number,Put in an
integer greater than 1:,entryInit=numAll))
tkdestroy(ttMain)

while (is.na(numAll) || numAll==0 || numAll==1) {
ttMain - tktoplevel()
tkfocus(ttMain)
ReturnVal -
tkmessageBox(title=Number,message=Error! The number
of should be NUMERICAL and be greater than
1!,icon=info,type=ok)
tkdestroy(ttMain)

ttMain - tktoplevel()
tkfocus(ttMain)
numAll -
as.numeric(modalDialogOK(Number,Put in an integer
greater than 1:,entryInit=numAll))
tkdestroy(ttMain)

}


##===
## end of 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.


[R] R book needed

2008-10-09 Thread Hua Li
Hi there,

I'm looking for advice on a R book that's for somewhat advanced user. 

I've been using R for a while and can do the basic analysis with no problem. My 
problem is that for many already existing commands, such as gsub, 
textconnection, list, etc, I don't use them, simply because I don't know their 
existence! Can someone recommend a good book that I can refer to and can learn 
R systematically? 

Thanks a lot!

Hua

__
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] change the label size when drawing trees with ape

2009-02-19 Thread Hua Li

Hi All,

I want to be able to change the labe size on a tree
when using ape package so that the graph can look
nicer, but don't know how. Playing with the font
doesn't seem to help. (Right now the labels barely
show.) 

Thanks for your help!

Code I'm using now

#-
t1 = (((1:77.37,2:77.37):9.4,4:86.77):7.56,3:94.33);
t2 = ((1:12.56,(2:10.11,4:10.11):2.45):1.64,3:14.2);
t3= 
(((1:57.54,3:57.54):11.54,4:69.08):4.13,2:73.21);
t4 =
(1:59.27,((2:34.77,3:34.77):6.99,4:41.76):17.51);
t5 =
(((1:22.26,4:22.26):3.4,3:25.66):15.81,2:41.47);
t6 = (((1:23.3,2:23.3):22.2,3:45.5):37.88,4:83.38);
t7 =
(((1:18.49,3:18.49):1.14,4:19.63):5.93,2:25.56);
t8 =
((1:40.26,2:40.26):31.51,(3:38.99,4:38.99):32.78);
t9 =
(1:60.72,((2:15.57,4:15.57):5.07,3:20.64):40.08);
t10 =
((1:54.81,3:54.81):13.81,(2:64.24,4:64.24):4.380001);
t11 =
((1:61.44,3:61.44):26.94,(2:26.52,4:26.52):61.86);
t12 =
((1:11.05,(3:10.15,4:10.15):0.9):68.71,2:79.76);
t13 =
(((1:39.53,3:39.53):6.25,4:45.78):3.09,2:48.87);
t14 =
((1:55.12,(2:37.99,3:37.99):17.13):18.28,4:73.4);
t15 =
((1:73.39,(2:54.24,4:54.24):19.15):20.58,3:93.97);


library(ape)

ft = c(5,5,5,5)
postscript(test.ps)
par(mfrow=c(5,3))
plot(read.tree(text=t1),font=ft)
plot(read.tree(text=t2),font=ft)
plot(read.tree(text=t3),font=ft)
plot(read.tree(text=t4),font=ft)
plot(read.tree(text=t5),font=ft)
plot(read.tree(text=t6),font=ft)
plot(read.tree(text=t7),font=ft)
plot(read.tree(text=t8),font=ft)
plot(read.tree(text=t9),font=ft)
plot(read.tree(text=t10),font=ft)
plot(read.tree(text=t11),font=ft)
plot(read.tree(text=t12),font=ft)
plot(read.tree(text=t13),font=ft)
plot(read.tree(text=t14),font=ft)
plot(read.tree(text=t15),font=ft)
dev.off()

__
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] Install package of BRugs?

2010-03-30 Thread Hua Li
Hi All,

I'm trying to install the package BRugs and could not find it on the install 
package list. Then I tried the suggestion to run the following command in R

install.packages(BRugs)

but get the following error message:

Loading required package: BRugs
Warning message:
In library(package, lib.loc = lib.loc, character.only = TRUE, logical.return = 
TRUE,  :
  there is no package called 'BRugs'

and the command of 

library(BRugs) 

results in the following
Error in library(BRugs) : there is no package called 'BRugs'

So how can I install BRugs at this point? I'm using R 2.8.1 on Windows XP 
profession x64 edition.

Thanks a lot!

Hua

__
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] Fw: Install package of BRugs?

2010-03-30 Thread Hua Li
Sorry, I think I miscopied the error messages. Here they are.


install.packages(BRugs) 
Warning: unable to access index for repository 
http://www.stats.ox.ac.uk/pub/RWin/bin/windows/contrib/2.8
Warning message:
package ‘BRugs’ is not available 
 require(BRugs)
Loading required package: BRugs
Warning message:
In library(package, lib.loc = lib.loc, character.only = TRUE, logical.return = 
TRUE,  :
  there is no package called 'BRugs'
 library(BRugs) 
Error in library(BRugs) : there is no package called 'BRugs'




--- On Tue, 3/30/10, Hua Li huali...@yahoo.com wrote:

 From: Hua Li huali...@yahoo.com
 Subject: Install package of BRugs?
 To: R-help r-help@r-project.org
 Date: Tuesday, March 30, 2010, 3:42 PM
 Hi All,
 
 I'm trying to install the package BRugs and could not
 find it on the install package list. Then I tried the
 suggestion to run the following command in R
 
 install.packages(BRugs)
 
 but get the following error message:
 
 Loading required package: BRugs
 Warning message:
 In library(package, lib.loc = lib.loc, character.only =
 TRUE, logical.return = TRUE,  :
   there is no package called 'BRugs'
 
 and the command of 
 
 library(BRugs) 
 
 results in the following
 Error in library(BRugs) : there is no package called
 'BRugs'
 
 So how can I install BRugs at this point? I'm using R 2.8.1
 on Windows XP profession x64 edition.
 
 Thanks a lot!
 
 Hua
 
 
       
 




__
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.


Re: [R] Install package of BRugs?

2010-03-31 Thread Hua Li
Thanks! I updated R to 2.10.1 and everything is fine now!

Hua

--- On Wed, 3/31/10, Uwe Ligges lig...@statistik.tu-dortmund.de wrote:

 From: Uwe Ligges lig...@statistik.tu-dortmund.de
 Subject: Re: [R] Install package of BRugs?
 To: David Winsemius dwinsem...@comcast.net
 Cc: Hua Li huali...@yahoo.com, R-help r-help@r-project.org
 Date: Wednesday, March 31, 2010, 2:53 AM
 
 
 On 30.03.2010 22:01, David Winsemius wrote:
 
  On Mar 30, 2010, at 3:42 PM, Hua Li wrote:
 
  Hi All,
 
  I'm trying to install the package BRugs and
 could not find it on the
  install package list. Then I tried the suggestion
 to run the following
  command in R
 
  install.packages(BRugs)
 
  but get the following error message:
 
  Loading required package: BRugs
  Warning message:
  In library(package, lib.loc = lib.loc,
 character.only = TRUE,
  logical.return = TRUE, :
  there is no package called 'BRugs'
 
  and the command of
 
  library(BRugs)
 
  results in the following
  Error in library(BRugs) : there is no package
 called 'BRugs'
 
  So how can I install BRugs at this point? I'm
 using R 2.8.1 on Windows
  XP profession x64 edition.
 
 
  The glaringly obvious search strategy:
 
  r-project brugs
 
   on google provides this as the first hit:
 
  http://cran.r-project.org/web/packages/BRugs/
 
 
 BRugs is hosted on CRAN extras (Brian Ripley's special
 cases repository) 
 due to license specific issues.
 
 Please update your R and try 
 install.packages(BRugs)  again, you will 
 get it from CRAN extras which is a default repository under
 Windows 
 (unless you deselected it).
 
 Uwe Ligges
 
 
 
 
 
 
 
 
 
 
  Thanks a lot!
 
  Hua
 
  __
  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.
 
  David Winsemius, MD
  West Hartford, CT
 
  __
  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.