s-news
[Top] [All Lists]

Re: plot histogram of a distribution

To: "David L Lorenz" <lorenz@usgs.gov>
Subject: Re: plot histogram of a distribution
From: "Krishnamachari, Raghuraman" <Raghu.Krishnamachari@leggmasonasia.com.sg>
Date: Thu, 24 Aug 2006 05:47:14 -0700
Cc: <s-news@lists.biostat.wustl.edu>, <s-news-owner@lists.biostat.wustl.edu>
Thread-index: AcbHeW+zXAZAHqRUS8W+l9WyRaSHpwAARtKA
Thread-topic: [S] plot histogram of a distribution
Thanks a lot Dave.. It works.
 
But how to print the graphs in different pages of the same sheet.
i find that its overwriting in the same page.
 


From: David L Lorenz [mailto:lorenz@usgs.gov]
Sent: Thursday, August 24, 2006 8:33 PM
To: Krishnamachari, Raghuraman
Cc: s-news@lists.biostat.wustl.edu; s-news-owner@lists.biostat.wustl.edu
Subject: Re: [S] plot histogram of a distribution


Raghu,
  If you look at the formula in your for loop, you will see that it has exactly the same appearance as the one that works. That means the routines that evaluate the formula see the same thing and are looking at a column named f.name in the data set and not a column named FCF. You know that f.name is a variable that represents that column, but the routine that evaluates the formula does not.
  For cases like this, you can use the as.formula() function. Try this:

histogram(as.formula(paste("~", f.name, "| Country")), data="" = 10,type="count")

  I do not see where Country comes from if you select only the column f.name from data!
Dave



"Krishnamachari, Raghuraman" <Raghu.Krishnamachari@leggmasonasia.com.sg>
Sent by: s-news-owner@lists.biostat.wustl.edu

08/23/2006 09:52 PM

To
<s-news@lists.biostat.wustl.edu>
cc
Subject
[S] plot histogram of a distribution





Dear all,
 
I am new to this list and splus. I am trying to plot a histogram of a distribution using "histogram".
The issue is i am unable to call this in a loop with different Factors variables.
 
> factor.names
[1] "Tobin.Q" "EBITDA"  "FCF"

 
> factor.cols
[1] "Tobin.Q" "EBITDA"  "FCF"  

 
=================================
for(i in 1:length(factor.cols)) {

f.name<-factor.names[i]

histogram(~ f.name | Country, data="" = 10,type="count")
}
====================================

 
when i replace f.name with the numeric column names like FCF,EBITDA individually, the above function works. But how to pass these values in a loop.
 
histogram(~ FCF | Country, data="" = 10,type="count") -- works
 
whereas
 
histogram(~ "FCF" | Country, data="" = 10,type="count")
-- gives different results.
 
 
Hope someone throw light on this.
 
thanks,
 
Raghu.



**********************************************************************
E-mail sent through the Internet is not secure. Legg Mason Asset Management (Asia) Pte Ltd [Co. Reg. No. 200007692R] therefore recommends that you do not utilize electronic mail to send to us any confidential or sensitive information, including account numbers and personal identification numbers. Delivery, and/or timely delivery of Internet electronic mail is not guaranteed. Legg Mason Asset Management (Asia) Pte Ltd therefore recommends that you do not send time-sensitive or action-oriented messages to us via electronic mail.
**********************************************************************



**********************************************************************
E-mail sent through the Internet is not secure. Legg Mason Asset Management (Asia) Pte Ltd [Co. Reg. No. 200007692R] therefore recommends that you do not utilize electronic mail to send to us any confidential or sensitive information, including account numbers and personal identification numbers. Delivery, and/or timely delivery of Internet electronic mail is not guaranteed. Legg Mason Asset Management (Asia) Pte Ltd therefore recommends that you do not send time-sensitive or action-oriented messages to us via electronic mail.
**********************************************************************
<Prev in Thread] Current Thread [Next in Thread>