[R] plot rownames

Prof Brian Ripley ripley at stats.ox.ac.uk
Wed May 28 08:18:10 CEST 2008


On Tue, 27 May 2008, T.D.Rudolph wrote:

>
> In the following example:
> x <- rnorm(1:100)
> y <- seq(from=-2.5, to=3.5, by=0.5)
> z <- as.matrix(table(cut(x,c(-Inf, y, +Inf))))
>
> ## I wish to transform the values in z
> j <- log(z)
>
> ## Yet retain the row names
> row.names(j)<-row.names(z)

Hmm.  The rownames were retained and row.names() is for data frames, 
rownames() for matrices.

> Now, how can I go about creating a scatterplot with row.names(j) on the
> x-axis and j(m:nrow(j)) on the y-axis?  Keep in mind the transformation I am
> conducting is more complicated and therefore cannot be plotted directly
> using log(z), which places me in this unique position.

You will need to explain what exactly you want plotted.  A scatterplot is 
of two continuous variables and you only have one (and 'j(m:nrow(j))' is 
invaild R). But here is one possibility to get you started:

m <- nrow(j)
plot(j, xaxt="n", xlab="")
axis(1, 1:m, rownames(j), las=2)


>
> Tyler
> -- 
> View this message in context: http://www.nabble.com/plot-rownames-tp17504882p17504882.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> R-help at 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.
>

-- 
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 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595



More information about the R-help mailing list