Thanks very much for the replies.
Both suggestions worked perfectly.
That's one more step towards understanding R.
Thanks again.
--
View this message in context:
http://www.nabble.com/Row-order-in-plot-tp20962774p20974800.html
Sent from the R help mailing list archive at Nabble.com.
__
Though the results of using plot() with a factor may not always be what you
expect, as plot.factor() differs from plot().
Sarah
On Thu, Dec 11, 2008 at 4:36 PM, Peter Alspach
wrote:
> Tena koe
>
> Try
>
> mice$X <- factor(mice$X, levels=mice$X)
> plot(Green.1~X,data=mice)
>
> HTH
>
> Peter
Then yes, you can do something like I originally suggested, though there
are other possible approaches.
Making up fake data rather than typing yours in:
> testdata <- as.data.frame(matrix(1:15, ncol=3))
> testdata <- cbind(c("D", "E", "A", "C", "B"), testdata)
> colnames(testdata) <- c("X", "c1",
> To: r-help@r-project.org
> Subject: Re: [R] Row order in plot
>
>
> This is the format of the table as it appears in R
>
> >mice
>
> X Green.1 Yellow.2 Blue.3 Gray.4
> 1 Base 469.5399 508.1532 487.1443 492.2544
> 2PBS 459.6553
This is the format of the table as it appears in R
>mice
X Green.1 Yellow.2 Blue.3 Gray.4
1 Base 469.5399 508.1532 487.1443 492.2544
2PBS 459.6553 474.0124 417.2651 392.9518
3 25 Mch 359.6216 418.0417 377.7020 394.2102
4 50 Mch 206.1835 262.8818 252.80
It would be easier to answer your question if we knew what your
data look like, what R commands you've tried, and what result
you want.
One possibility: plot the data against 1:nrow(yourdata), and add
the row names as labels.
Sarah
On Thu, Dec 11, 2008 at 2:35 PM, qroberts wrote:
>
> I'm new to
I'm new to R so forgive me if this seems like a simple question:
So I have table where the row titles are string variables. When I plot the
data with rows along the x-axis, the data is ordered alphabetically as
opposed to the order of the table.
How can I preserve the row order of the table in t
7 matches
Mail list logo