# [R] About regression and plot

Romain Francois francoisromain at free.fr
Wed Apr 26 15:39:29 CEST 2006

```Le 26.04.2006 15:16, Daniel Yang a écrit :
> Dear R-help,
>
> This is my first R day.  I want to ask some more beginner's questions.
>
> Q1. How can I obtain the covariance matrix for parameter estimates of a multiple regression?  I checked ?lm but didn't get the information.
>
> Q2. How can I see the old graphs in the graph window?
>
> Q3. Can R plot animated graph?  For example, I want to see the dynamic change of a 2D graph during a time period.
>
> Yung-jui Yang
>
Welcome here,

You might want to learn R a few days, read the docs, etc .. and then
come back with questions.
That's how you will get the most of R.

R2 :
you can't, but you can open more than one graph at a time, with
?windows, or ?x11 or send a graphic to a file : ?pdf, ?png, ...
Or you reexecute the commands

R3 :
For a live animation :
x <- rnorm(100)
for(i in 1:100){
plot(1:i, x[1:i], xlim=c(0,100), ylim=range(x), type="l")
Sys.sleep(.1)
}

You may want to save each graphic in a file and then build an animation
using convert (from ImageMagick) or whatever tools you have.

In R :

png('gr_%04d.png', width=600, height=400)
x <- rnorm(100)
for(i in 1:100){
plot(1:i, x[1:i], xlim=c(0,100), ylim=range(x), type="l")
}
dev.off()

From a shell :
\$ convert *.png out.gif

http://pinard.progiciels-bpi.ca/plaisirs/animations/index.html
http://dirk.eddelbuettel.com/code/rquantlib-rgl.html

Romain

--
visit the R Graph Gallery : http://addictedtor.free.fr/graphiques
mixmod 1.7 is released : http://www-math.univ-fcomte.fr/mixmod/index.php
+---------------------------------------------------------------+
| Romain FRANCOIS - http://francoisromain.free.fr               |
| Doctorant INRIA Futurs / EDF                                  |
+---------------------------------------------------------------+

```