Witold Eryk Wolski
2001-Jan-17 16:23 UTC
[R] Is ther a possibility to display the log(frequency) instead of the frequency in the hist plot?
Is there a possibility to display the log(frequency) instead of the frequency in the hist? -- Witold Eryk Wolski Max Plank Institut fuer Molekulare Genetik Ihnestr73 14195 Berlin Germany tel.: Work 0049-30-84131426 http://www.molgen.mpg.de/~wolski -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
Uwe Ligges
2001-Jan-17 21:08 UTC
[R] Is ther a possibility to display the log(frequency) instead of the frequency in the hist plot?
Witold Eryk Wolski wrote:> > Is there a possibility to display the log(frequency) instead of the > frequency in the hist?I think you want something like the following example: x <- runif(100) * 10 my.hist <- hist(x) my.hist # have a look at the values! my.hist$counts <- log(my.hist$counts, 10) # logarithm with base 10 plot(my.hist) # now plot it again with log(frequency) Uwe Ligges -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
Witold Eryk Wolski
2001-Jan-18 08:27 UTC
[R] Is ther a possibility to display the log(frequency) instead of the frequency in the hist plot?
Uwe Ligges wrote:> Witold Eryk Wolski wrote: > > > > Is there a possibility to display the log(frequency) instead of the > > frequency in the hist? > > I think you want something like the following example: > > x <- runif(100) * 10 > my.hist <- hist(x) > my.hist # have a look at the values! > my.hist$counts <- log(my.hist$counts, 10) # logarithm with base 10 > plot(my.hist) # now plot it again with log(frequency) > > Uwe Ligges >Hi Uwe! First thanks for your answer. Some questions still remain to me. 1. How take an log if one of the my.hist$counts equals 0? 2. You code expample produces an error message which i doesnt understand.> plot(my.hist) # now plot it again with log(frequency)Error in plot.window(xlim, ylim, log, asp, ...) : invalid xlim 3. I tried as workaround something similar. plot(my.hist$mids,log(my.hist$counts),type="s") And this would work quite good for my needs. But problem with log(0) = -Inf still remains. I think I have to formulate my question more general. Why, and this is an question which I am asking myself since I am started using R becouse im using the hist plot quite often, the hist plot in the base package has no similar options like eg. the histogram plot in XMGR? THX Eryk> -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- > r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html > Send "info", "help", or "[un]subscribe" > (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch > _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._-- Witold Eryk Wolski Max Plank Institut fuer Molekulare Genetik Ihnestr73 14195 Berlin Germany tel.: Work 0049-30-84131426 http://www.molgen.mpg.de/~wolski -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
Uwe Ligges
2001-Jan-18 09:46 UTC
[R] Is ther a possibility to display the log(frequency) instead of the frequency in the hist plot?
Witold Eryk Wolski wrote:> > Uwe Ligges wrote: > > > Witold Eryk Wolski wrote: > > > > > > Is there a possibility to display the log(frequency) instead of the > > > frequency in the hist? > > > > I think you want something like the following example: > > > > x <- runif(100) * 10 > > my.hist <- hist(x) > > my.hist # have a look at the values! > > my.hist$counts <- log(my.hist$counts, 10) # logarithm with base 10 > > plot(my.hist) # now plot it again with log(frequency) > > > > Uwe Ligges > > > > Hi Uwe! > First thanks for your answer. > Some questions still remain to me. > 1. How take an log if one of the my.hist$counts equals 0?You want to use a histogram, so you have to think about what you want to do in that case.> 2. You code expample produces an error message which i doesnt understand. > > plot(my.hist) # now plot it again with log(frequency) > Error in plot.window(xlim, ylim, log, asp, ...) : > invalid xlim??? No, cannot reproduce it with my example!> 3. I tried as workaround something similar. > plot(my.hist$mids,log(my.hist$counts),type="s") And this would work quite good for > my needs. > But problem with log(0) = -Inf still remains.So we have to change the mathematical axioms. ;-)> I think I have to formulate my question more general. Why, and this is an question > which I am asking myself since > I am started using R becouse im using the hist plot quite often, the hist plot in > the base package has no similar > options like eg. the histogram plot in XMGR? > > THX > ErykUwe Ligges -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
Peter Kleiweg
2001-Jan-18 11:46 UTC
[R] Is ther a possibility to display the log(frequency) instead of the frequency in the hist plot?
Witold Eryk Wolski skriver...> Some questions still remain to me. > 1. How take an log if one of the my.hist$counts equals 0?log(my.hist$counts + 1) -- Peter Kleiweg http://www.let.rug.nl/~kleiweg/ -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
ben@zoo.ufl.edu
2001-Jan-18 16:26 UTC
[R] Is ther a possibility to display the log(frequency) instead of the frequency in the hist plot?
On Thu, 18 Jan 2001, Witold Eryk Wolski wrote:> Uwe Ligges wrote: > > > Witold Eryk Wolski wrote: > > > > > > Is there a possibility to display the log(frequency) instead of the > > > frequency in the hist? > > > > I think you want something like the following example: > > > > x <- runif(100) * 10 > > my.hist <- hist(x) > > my.hist # have a look at the values! > > my.hist$counts <- log(my.hist$counts, 10) # logarithm with base 10 > > plot(my.hist) # now plot it again with log(frequency) > > > > Uwe Ligges > > > > Hi Uwe! > First thanks for your answer. > Some questions still remain to me. > 1. How take an log if one of the my.hist$counts equals 0?You could try log10(my.hist$counts+1), which is a standard transformation in ecology.> 2. You code expample produces an error message which i doesnt understand. > > plot(my.hist) # now plot it again with log(frequency) > Error in plot.window(xlim, ylim, log, asp, ...) : > invalid xlimI don''t get it here either. Are you doing _exactly_ what Uwe suggested above? Or are you doing the histogram etc. on your own data (rather than a sample from runif())? What is the range of your data?> 3. I tried as workaround something similar. > plot(my.hist$mids,log(my.hist$counts),type="s") And this would work quite good for > my needs. > But problem with log(0) = -Inf still remains. > > I think I have to formulate my question more general. Why, and this is an question > which I am asking myself since > I am started using R becouse im using the hist plot quite often, the hist plot in > the base package has no similar > options like eg. the histogram plot in XMGR?What are those options? The general answers to the questions "why doesn''t R have ... ?" are usually: 1. it would be a useful feature, but no-one has thought of/suggested it yet (?); 2. ditto, but no-one has had the time or energy or specific knowledge required to code it (e.g. full integration of 3D graphics, GAM); 3. it represents something that at least some people (the R Core team, who tend to be awfully knowledgeable about statistical and graphical issues) think is a bad idea (e.g. type III sums of squares); 4. it is minor enough, or there is an easy enough way to work around it, that spending time on it/"bloating" R with it doesn''t seem worthwhile. Ben -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
Alexander A. Morgan
2001-Jan-18 19:05 UTC
[R] Is ther a possibility to display the log(frequency) instead of the frequency in the hist plot?
I imagine that the point of logging the histogram count axis is just for displaying purposes, and your suggestion would alter the scale. I find it easier to just leave the 0 counts as zero. hist(my.data, plot=F)$counts -> my.hist.counts; my.hist.counts[my.hist.counts != 0] <- log(my.hist.counts[my.hist.counts!= 0]); plot(my.hist.counts, type="hist"); -Alex Morgan Phone: 781-271-6306 "They laughed at Newton. Office: 3K-136 They laughed at Einstein. AOL Instant Messenger: HomeySage But they also laughed at Groucho Marx." --Carl Sagan On Thu, 18 Jan 2001, Peter Kleiweg wrote:> Witold Eryk Wolski skriver... > > > Some questions still remain to me. > > 1. How take an log if one of the my.hist$counts equals 0? > > log(my.hist$counts + 1) > > -- > Peter Kleiweg > http://www.let.rug.nl/~kleiweg/ > > -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- > r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html > Send "info", "help", or "[un]subscribe" > (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch > _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._ >-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
ben@zoo.ufl.edu
2001-Jan-18 21:54 UTC
[R] Is ther a possibility to display the log(frequency) instead of the frequency in the hist plot?
The only potential problem with this solution is that bins with zero counts and bins with 1 count will both be treated as zeros. Consider: my.data <- c(1.5,1.5,2.5,4.5,5.5,5.5) my.hist.counts <- hist(my.data, plot=F, breaks=0:6)$counts etc. This is an unlikely event with the default "breaks" settings, though. (On the other hand, the fact that you have bins with zero counts says that you might well have bins with only 1 count.) Ben On Thu, 18 Jan 2001, Alexander A. Morgan wrote:> I imagine that the point of logging the histogram count axis is just for > displaying purposes, and your suggestion would alter the scale. I find it > easier to just leave the 0 counts as zero. > > hist(my.data, plot=F)$counts -> my.hist.counts; > my.hist.counts[my.hist.counts != 0] <- > log(my.hist.counts[my.hist.counts!= 0]); > plot(my.hist.counts, type="hist"); > > > -Alex Morgan > > Phone: 781-271-6306 "They laughed at Newton. > Office: 3K-136 They laughed at Einstein. > AOL Instant Messenger: HomeySage But they also laughed at Groucho > Marx." > --Carl Sagan > > On Thu, 18 Jan 2001, Peter Kleiweg wrote: > > > Witold Eryk Wolski skriver... > > > > > Some questions still remain to me. > > > 1. How take an log if one of the my.hist$counts equals 0? > > > > log(my.hist$counts + 1) > > > > -- > > Peter Kleiweg > > http://www.let.rug.nl/~kleiweg/ > > > > -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- > > r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html > > Send "info", "help", or "[un]subscribe" > > (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch > > _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._ > > > > -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- > r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html > Send "info", "help", or "[un]subscribe" > (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch > _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._ >-- 318 Carr Hall bolker at zoo.ufl.edu Zoology Department, University of Florida http://www.zoo.ufl.edu/bolker Box 118525 (ph) 352-392-5697 Gainesville, FL 32611-8525 (fax) 352-392-3704 -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._