| To: | <s-news@lists.biostat.wustl.edu> |
|---|---|
| Subject: | Re: plot histogram of a distribution |
| From: | "Krishnamachari, Raghuraman" <Raghu.Krishnamachari@leggmasonasia.com.sg> |
| Date: | Tue, 29 Aug 2006 01:12:55 -0700 |
| Cc: | "David L Lorenz" <lorenz@usgs.gov> |
| Thread-index: | AcbHeW+zXAZAHqRUS8W+l9WyRaSHpwAARtKAAPH0qmA= |
| Thread-topic: | [S] plot histogram of a distribution |
|
the below for loop works well, but when i try to wrap
it inside a function, the f.name[i] is not getting passed
correctly.
Fngraphs<-function(data,factor.names)
{ for(i in 1:length(factor.cols)) {
f.name<-factor.names[i] t1<-histogram(as.formula(paste("~", f.name[i], "| Country")), data="" = 10,type="count") print(t1) } } Any workaround for this?? From: Krishnamachari, Raghuraman Sent: Thursday, August 24, 2006 8:47 PM To: 'David L Lorenz' Cc: s-news@lists.biostat.wustl.edu; s-news-owner@lists.biostat.wustl.edu Subject: RE: [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
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> |
|---|---|---|
| ||
| Previous by Date: | Re: About shape.plot, Eric Zivot |
|---|---|
| Next by Date: | sigma symbol, Chris Moyer |
| Previous by Thread: | Re: plot histogram of a distribution, Krishnamachari, Raghuraman |
| Next by Thread: | nonlinear regression, Paternostro . Amy |
| Indexes: | [Date] [Thread] [Top] [All Lists] |