[R] Ploting a matrix

2009-03-27 Thread skrug

Hi evrybody,

in a matrix consisting of 49 columns, I would like to plot all columns 
against the first in 48 different graphs.

Can you help me?

Thank you in advance
Sebastian

--
***

Dipl. Biol. Sebastian Krug
PhD - student
IFM - GEOMAR
Leibniz Institute of Marine Sciences
Research Division 2 - Marine Biogeochemistry
Düsternbrooker Weg 20
D - 24105 Kiel
Germany

Tel.: +49 431 600-4282
Fax.: +49 431 600-4446
email: sk...@ifm-geomar.de

__
R-help@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.


Re: [R] Ploting a matrix

2009-03-27 Thread baptiste auguie

Something like this perhaps,


a - matrix(rnorm(5*49), ncol=49)

pdf(width=15, height=15)

par(mfrow= c(8,6))
apply(a[,-1], 2, plot, x= a[,1])

dev.off()



HTH,

baptiste

On 27 Mar 2009, at 11:05, skrug wrote:


Hi evrybody,

in a matrix consisting of 49 columns, I would like to plot all columns
against the first in 48 different graphs.
Can you help me?

Thank you in advance
Sebastian

--
***

Dipl. Biol. Sebastian Krug
PhD - student
IFM - GEOMAR
Leibniz Institute of Marine Sciences
Research Division 2 - Marine Biogeochemistry
Düsternbrooker Weg 20
D - 24105 Kiel
Germany

Tel.: +49 431 600-4282
Fax.: +49 431 600-4446
email: sk...@ifm-geomar.de

__
R-help@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.


_

Baptiste Auguié

School of Physics
University of Exeter
Stocker Road,
Exeter, Devon,
EX4 4QL, UK

Phone: +44 1392 264187

http://newton.ex.ac.uk/research/emag

__
R-help@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.


[R] Ploting a matrix

2009-03-27 Thread skrug
Unfortunately, I could not solve the problem of plotting all columns of 
a matrix against the first column


I used:

b=read.table(d:\\programme\\R\\übungen\\Block 1b.txt, header=T)

b is a table with the first column using  Dates and the following 
columns with vectors.


apply(b[,-1], 2, plot, x= b[,1])

Also all columns have the same length, [R] states that the length are 
different.


Can you help me?



baptiste auguie schrieb:

Something like this perhaps,


a - matrix(rnorm(5*49), ncol=49)

pdf(width=15, height=15)

par(mfrow= c(8,6))
apply(a[,-1], 2, plot, x= a[,1])

dev.off()



HTH,

baptiste

On 27 Mar 2009, at 11:05, skrug wrote:


Hi evrybody,

in a matrix consisting of 49 columns, I would like to plot all columns
against the first in 48 different graphs.
Can you help me?

Thank you in advance
Sebastian

--
*** 



Dipl. Biol. Sebastian Krug
PhD - student
IFM - GEOMAR
Leibniz Institute of Marine Sciences
Research Division 2 - Marine Biogeochemistry
Düsternbrooker Weg 20
D - 24105 Kiel
Germany

Tel.: +49 431 600-4282
Fax.: +49 431 600-4446
email: sk...@ifm-geomar.de

__
R-help@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.


_

Baptiste Auguié

School of Physics
University of Exeter
Stocker Road,
Exeter, Devon,
EX4 4QL, UK

Phone: +44 1392 264187

http://newton.ex.ac.uk/research/emag
__




--
***

Dipl. Biol. Sebastian Krug
PhD - student
IFM - GEOMAR
Leibniz Institute of Marine Sciences
Research Division 2 - Marine Biogeochemistry
Düsternbrooker Weg 20
D - 24105 Kiel
Germany

Tel.: +49 431 600-4282
Fax.: +49 431 600-4446
email: sk...@ifm-geomar.de

__
R-help@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.


Re: [R] Ploting a matrix

2009-03-27 Thread baptiste auguie
the result of read.table is a data.frame, not a matrix as you first  
suggested. Can you copy the result of str(b) so we know what your data  
is made of?


I'm guessing the most elegant solution will be to use the reshape  
package, followed by ggplot2 or lattice.


baptiste

On 27 Mar 2009, at 14:54, skrug wrote:

Unfortunately, I could not solve the problem of plotting all columns  
of

a matrix against the first column

I used:

b=read.table(d:\\programme\\R\\übungen\\Block 1b.txt, header=T)

b is a table with the first column using  Dates and the following
columns with vectors.

apply(b[,-1], 2, plot, x= b[,1])

Also all columns have the same length, [R] states that the length are
different.

Can you help me?



baptiste auguie schrieb:

Something like this perhaps,


a - matrix(rnorm(5*49), ncol=49)

pdf(width=15, height=15)

par(mfrow= c(8,6))
apply(a[,-1], 2, plot, x= a[,1])

dev.off()



HTH,

baptiste

On 27 Mar 2009, at 11:05, skrug wrote:


Hi evrybody,

in a matrix consisting of 49 columns, I would like to plot all  
columns

against the first in 48 different graphs.
Can you help me?

Thank you in advance
Sebastian

--
***


Dipl. Biol. Sebastian Krug
PhD - student
IFM - GEOMAR
Leibniz Institute of Marine Sciences
Research Division 2 - Marine Biogeochemistry
Düsternbrooker Weg 20
D - 24105 Kiel
Germany

Tel.: +49 431 600-4282
Fax.: +49 431 600-4446
email: sk...@ifm-geomar.de

__
R-help@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.


_

Baptiste Auguié

School of Physics
University of Exeter
Stocker Road,
Exeter, Devon,
EX4 4QL, UK

Phone: +44 1392 264187

http://newton.ex.ac.uk/research/emag
__




--
***

Dipl. Biol. Sebastian Krug
PhD - student
IFM - GEOMAR
Leibniz Institute of Marine Sciences
Research Division 2 - Marine Biogeochemistry
Düsternbrooker Weg 20
D - 24105 Kiel
Germany

Tel.: +49 431 600-4282
Fax.: +49 431 600-4446
email: sk...@ifm-geomar.de



_

Baptiste Auguié

School of Physics
University of Exeter
Stocker Road,
Exeter, Devon,
EX4 4QL, UK

Phone: +44 1392 264187

http://newton.ex.ac.uk/research/emag

__
R-help@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.


Re: [R] Ploting a matrix

2009-03-27 Thread skrug
Sorry for the mistake. As you probably already guesed, I am just 
starting using R. I could not name the difference between a matrix and a 
data.frame.


 str(b)
'data.frame':   9 obs. of  7 variables:
$ Datum: Factor w/ 9 levels 06.03.,07.03.,..: 1 2 3 4 5 6 7 8 9
$ X1   : int  408 335 2123 4685 7669 17060 31330 70730 109667
$ X2   : int  230 241 1509 2226 7839 13997 24797 53133 93061
$ X3   : int  25 16 38 61 114 299 140 172 196
$ X4   : int  248 588 2083 2071 4563 9798 17611 38554 82354
$ X5   : int  407 201 1339 3699 8375 19200 36563 83993 123167
$ X6   : int  248 730 3056 2327 4092 8905 15931 37895 84565



Thanks





baptiste auguie schrieb:
the result of read.table is a data.frame, not a matrix as you first 
suggested. Can you copy the result of str(b) so we know what your data 
is made of?


I'm guessing the most elegant solution will be to use the reshape 
package, followed by ggplot2 or lattice.


baptiste

On 27 Mar 2009, at 14:54, skrug wrote:


Unfortunately, I could not solve the problem of plotting all columns of
a matrix against the first column

I used:

b=read.table(d:\\programme\\R\\übungen\\Block 1b.txt, header=T)

b is a table with the first column using  Dates and the following
columns with vectors.

apply(b[,-1], 2, plot, x= b[,1])

Also all columns have the same length, [R] states that the length are
different.

Can you help me?



baptiste auguie schrieb:

Something like this perhaps,


a - matrix(rnorm(5*49), ncol=49)

pdf(width=15, height=15)

par(mfrow= c(8,6))
apply(a[,-1], 2, plot, x= a[,1])

dev.off()



HTH,

baptiste

On 27 Mar 2009, at 11:05, skrug wrote:


Hi evrybody,

in a matrix consisting of 49 columns, I would like to plot all columns
against the first in 48 different graphs.
Can you help me?

Thank you in advance
Sebastian

--
*** 




Dipl. Biol. Sebastian Krug
PhD - student
IFM - GEOMAR
Leibniz Institute of Marine Sciences
Research Division 2 - Marine Biogeochemistry
Düsternbrooker Weg 20
D - 24105 Kiel
Germany

Tel.: +49 431 600-4282
Fax.: +49 431 600-4446
email: sk...@ifm-geomar.de

__
R-help@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.


_

Baptiste Auguié

School of Physics
University of Exeter
Stocker Road,
Exeter, Devon,
EX4 4QL, UK

Phone: +44 1392 264187

http://newton.ex.ac.uk/research/emag
__




--
*** 



Dipl. Biol. Sebastian Krug
PhD - student
IFM - GEOMAR
Leibniz Institute of Marine Sciences
Research Division 2 - Marine Biogeochemistry
Düsternbrooker Weg 20
D - 24105 Kiel
Germany

Tel.: +49 431 600-4282
Fax.: +49 431 600-4446
email: sk...@ifm-geomar.de



_

Baptiste Auguié

School of Physics
University of Exeter
Stocker Road,
Exeter, Devon,
EX4 4QL, UK

Phone: +44 1392 264187

http://newton.ex.ac.uk/research/emag
__




--
***

Dipl. Biol. Sebastian Krug
PhD - student
IFM - GEOMAR
Leibniz Institute of Marine Sciences
Research Division 2 - Marine Biogeochemistry
Düsternbrooker Weg 20
D - 24105 Kiel
Germany

Tel.: +49 431 600-4282
Fax.: +49 431 600-4446
email: sk...@ifm-geomar.de

__
R-help@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.


Re: [R] Ploting a matrix

2009-03-27 Thread baptiste auguie
Here's my suggestion using the ggplot2 package (but you may prefer to  
stick with base functions),



date = factor(letters[1:9])
d - data.frame(x1=seq(1, 9), x2=seq(2, 10), date=date)

head(d) # dummy data that resembles yours
str(d)

library(reshape)
md - melt(d, id=date) # creates a data.frame in the long format
head(md)

library(ggplot2)

qplot(date, value, data=md, geom=point) + facet_wrap(~variable) #  
the layout is done automatically for you

# see Hadley's book for customisations
# http://had.co.nz/ggplot2/facet_wrap.html


HTH,

baptiste

On 27 Mar 2009, at 15:19, skrug wrote:


Sorry for the mistake. As you probably already guesed, I am just
starting using R. I could not name the difference between a matrix  
and a

data.frame.


str(b)

'data.frame':   9 obs. of  7 variables:
$ Datum: Factor w/ 9 levels 06.03.,07.03.,..: 1 2 3 4 5 6 7 8 9
$ X1   : int  408 335 2123 4685 7669 17060 31330 70730 109667
$ X2   : int  230 241 1509 2226 7839 13997 24797 53133 93061
$ X3   : int  25 16 38 61 114 299 140 172 196
$ X4   : int  248 588 2083 2071 4563 9798 17611 38554 82354
$ X5   : int  407 201 1339 3699 8375 19200 36563 83993 123167
$ X6   : int  248 730 3056 2327 4092 8905 15931 37895 84565



Thanks





baptiste auguie schrieb:

the result of read.table is a data.frame, not a matrix as you first
suggested. Can you copy the result of str(b) so we know what your  
data

is made of?

I'm guessing the most elegant solution will be to use the reshape
package, followed by ggplot2 or lattice.

baptiste

On 27 Mar 2009, at 14:54, skrug wrote:

Unfortunately, I could not solve the problem of plotting all  
columns of

a matrix against the first column

I used:

b=read.table(d:\\programme\\R\\übungen\\Block 1b.txt, header=T)

b is a table with the first column using  Dates and the following
columns with vectors.

apply(b[,-1], 2, plot, x= b[,1])

Also all columns have the same length, [R] states that the length  
are

different.

Can you help me?



baptiste auguie schrieb:

Something like this perhaps,


a - matrix(rnorm(5*49), ncol=49)

pdf(width=15, height=15)

par(mfrow= c(8,6))
apply(a[,-1], 2, plot, x= a[,1])

dev.off()



HTH,

baptiste

On 27 Mar 2009, at 11:05, skrug wrote:


Hi evrybody,

in a matrix consisting of 49 columns, I would like to plot all  
columns

against the first in 48 different graphs.
Can you help me?

Thank you in advance
Sebastian

--
***



Dipl. Biol. Sebastian Krug
PhD - student
IFM - GEOMAR
Leibniz Institute of Marine Sciences
Research Division 2 - Marine Biogeochemistry
Düsternbrooker Weg 20
D - 24105 Kiel
Germany

Tel.: +49 431 600-4282
Fax.: +49 431 600-4446
email: sk...@ifm-geomar.de

__
R-help@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.


_

Baptiste Auguié

School of Physics
University of Exeter
Stocker Road,
Exeter, Devon,
EX4 4QL, UK

Phone: +44 1392 264187

http://newton.ex.ac.uk/research/emag
__




--
***


Dipl. Biol. Sebastian Krug
PhD - student
IFM - GEOMAR
Leibniz Institute of Marine Sciences
Research Division 2 - Marine Biogeochemistry
Düsternbrooker Weg 20
D - 24105 Kiel
Germany

Tel.: +49 431 600-4282
Fax.: +49 431 600-4446
email: sk...@ifm-geomar.de



_

Baptiste Auguié

School of Physics
University of Exeter
Stocker Road,
Exeter, Devon,
EX4 4QL, UK

Phone: +44 1392 264187

http://newton.ex.ac.uk/research/emag
__




--
***

Dipl. Biol. Sebastian Krug
PhD - student
IFM - GEOMAR
Leibniz Institute of Marine Sciences
Research Division 2 - Marine Biogeochemistry
Düsternbrooker Weg 20
D - 24105 Kiel
Germany

Tel.: +49 431 600-4282
Fax.: +49 431 600-4446
email: sk...@ifm-geomar.de



_

Baptiste Auguié

School of Physics
University of Exeter
Stocker Road,
Exeter, Devon,
EX4 4QL, UK

Phone: +44 1392 264187

http://newton.ex.ac.uk/research/emag

__
R-help@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.


Re: [R] Ploting a matrix

2009-03-27 Thread Jorge Ivan Velez
Dear Sebastian,
Consider matplot() for this. Here is an example (taken from Baptiste
Auguie's post):

 date - factor(letters[1:9])
 d - data.frame(x1=seq(1, 9), x2=seq(2, 10), date=date)
 matplot(d[,-3],pch=16,xaxt='n',las=1,ylab='Some label here',xlab='Date')
 axis(1,d[,3],d[,3])
 legend('topleft',c('x1','x2'),pch=16,col=1:2)

See ?matplot, ?axis and ?legend for more information.

HTH,

Jorge


On Fri, Mar 27, 2009 at 7:05 AM, skrug sk...@ifm-geomar.de wrote:

 Hi evrybody,

 in a matrix consisting of 49 columns, I would like to plot all columns
 against the first in 48 different graphs.
 Can you help me?

 Thank you in advance
 Sebastian

 --

 ***

 Dipl. Biol. Sebastian Krug
 PhD - student
 IFM - GEOMAR
 Leibniz Institute of Marine Sciences
 Research Division 2 - Marine Biogeochemistry
 Düsternbrooker Weg 20
 D - 24105 Kiel
 Germany

 Tel.: +49 431 600-4282
 Fax.: +49 431 600-4446
 email: sk...@ifm-geomar.de

 __
 R-help@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.


[[alternative HTML version deleted]]

__
R-help@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.