Dear friends, I have been following the help-list in the next two months and I would like to tell how much I admire the effort of such a great teem of R expert. I am learning a lot. Thank you. My problem is the following. I work with a fairly large data set (700 productive sectors, 70 countries, 25 years) and I am applying kernel density (using MASS or sm) to sectoral exports which have markedly skewed distributions, so I do the analysis on a log scale. What I would like when I plot histograms or densities is to have on the horizontal axis not the value y which is equal to log(x) but the expression log(x) itself (i.e. log(0.3), log(1), log(34),...) I have played a little bit with names.arg : plot(density(log(x[,3]),width=0.4, names.arg="log(x)") but I was not very successful. Any suggestion would be appreciated. Thanks. Luca -------------- next part -------------- A non-text attachment was scrubbed... Name: debene.vcf Type: text/x-vcard Size: 321 bytes Desc: Card for Luca De Benedictis Url : https://stat.ethz.ch/pipermail/r-help/attachments/20020612/39ca499d/debene.vcf
On Wed, 12 Jun 2002, Luca De Benedictis wrote:> Dear friends, > I have been following the help-list in the next two months and I would > like to tell how much I admire the effort of such a great teem of R > expert. I am learning a lot. Thank you. > > My problem is the following. I work with a fairly large data set (700 > productive sectors, 70 countries, 25 years) and I am applying kernel > density (using MASS or sm) to sectoral exports which have markedly > skewed distributions, so I do the analysis on a log scale. > What I would like when I plot histograms or densities is to have on the > horizontal axis not the value y which is equal to log(x) but the > expression log(x) itself (i.e. log(0.3), log(1), log(34),...) > > I have played a little bit with names.arg : > plot(density(log(x[,3]),width=0.4, names.arg="log(x)") > > but I was not very successful. Any suggestion would be appreciated.How about x <- rlnorm(700) den <- density(log(x)) den$x <- exp(den$x) plot(den, log="x", title="something meaningful") ? -- Brian D. Ripley, ripley at stats.ox.ac.uk 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 272860 (secr) Oxford OX1 3TG, UK Fax: +44 1865 272595 -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- 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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
If your initial values are 1:10, a <- paste(paste("log(",1:10,sep=""),")",sep="") would give you a vector string a:> a[1] "log(1)" "log(2)" "log(3)" "log(4)" "log(5)" "log(6)" "log(7)" [8] "log(8)" "log(9)" "log(10)" You can use "a" for in the histogram in a number of ways. Faster:> b <- rnorm(100) > b <- b[b>0] > hist(b)note tick labels in the x-axis. Here from 0 to 3 by 0.5:> hist(b,labels=paste(paste("log(",seq(0,3,0.5),sep=""),")",sep=""))Better:> hist(b,axes=F) > axis(1,labels=paste(paste("log(",seq(0,3,0.5),sep=""),")",sep="")) > axis(2)Agus Dr. Agustin Lobo Instituto de Ciencias de la Tierra (CSIC) Lluis Sole Sabaris s/n 08028 Barcelona SPAIN tel 34 93409 5410 fax 34 93411 0012 alobo at ija.csic.es On Wed, 12 Jun 2002, Luca De Benedictis wrote:> Dear friends, > I have been following the help-list in the next two months and I would > like to tell how much I admire the effort of such a great teem of R > expert. I am learning a lot. Thank you. > > My problem is the following. I work with a fairly large data set (700 > productive sectors, 70 countries, 25 years) and I am applying kernel > density (using MASS or sm) to sectoral exports which have markedly > skewed distributions, so I do the analysis on a log scale. > What I would like when I plot histograms or densities is to have on the > horizontal axis not the value y which is equal to log(x) but the > expression log(x) itself (i.e. log(0.3), log(1), log(34),...) > > I have played a little bit with names.arg : > plot(density(log(x[,3]),width=0.4, names.arg="log(x)") > > but I was not very successful. Any suggestion would be appreciated. > Thanks. > > Luca >-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- 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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
The example I sent was intended to show how to make the tick labels with paste(), not the distribution, of course. Agus Dr. Agustin Lobo Instituto de Ciencias de la Tierra (CSIC) Lluis Sole Sabaris s/n 08028 Barcelona SPAIN tel 34 93409 5410 fax 34 93411 0012 alobo at ija.csic.es -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- 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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._