Thank you Jean and Patrick for your simple and very S-instructive anwer.
My question and their anwers here below.
===========================
Gianfranco MASTRACCHIO wrote:
>I have a df with say 5 columns, being 10-long vectors, corresponding to
>10 repeated measures performed at 5 different temperatures. I want a
>simple scatter plot or boxplot, with Y being the 50 measured values and
>x the temperature level.
>
>It is possible by trasforming the df from 10x5 to 50x1 and adding a new
>col for x axis and using plot or boxplot, but I wonder if there is a
>more direct way....
>
>using S+ 6.2 under win XP
>
>thanks in advance
>Gianfranco
=============================
Here's a simple scatter plot:
df <- data.frame(matrix(sample(50), ncol=5))
temps <- c(10, 15, 18, 20, 25)
plot(temps[as.vector(col(df))], unlist(df))
JVA
`·.,, ><(((º> `·.,, ><(((º> `·.,, ><(((º>
Jean V. Adams
Statistician
U.S. Geological Survey
Great Lakes Science Center
c/o Marquette Biological Station
1924 Industrial Parkway
Marquette, MI 49855 USA
phone: 906-226-1212
FAX: 906-226-3632
web site: www.glsc.usgs.gov
e-mail: jvadams@usgs.gov
I haven't tried this, but something like the following should work:
plot(temperatures[col(x)], x)
If 'x' is a data frame, you may have to say
as.matrix(x)
Patrick Burns
patrick@burns-stat.com
+44 (0)20 8525 0696
http://www.burns-stat.com
(home of S Poetry and "A Guide for the Unwilling S User")
|