<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"> <!--Converted with LaTeX2HTML 98.2 beta6 (August 14th, 1998) original version by:  Nikos Drakos, CBLU, University of Leeds * revised and updated by:  Marcus Hennecke, Ross Moore, Herb Swan * with significant contributions from:   Jens Lippmann, Marek Rouchal, Martin Wilck and others --> <HTML> <HEAD> <TITLE>matrix</TITLE> <META NAME="description" CONTENT="matrix"> <META NAME="keywords" CONTENT="tp1"> <META NAME="resource-type" CONTENT="document"> <META NAME="distribution" CONTENT="global"> <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1"> <LINK REL="STYLESHEET" HREF="tp1.css"> <LINK REL="next" HREF="node8.html"> <LINK REL="previous" HREF="node6.html"> <LINK REL="up" HREF="node3.html"> <LINK REL="next" HREF="node8.html"> </HEAD> <BODY > <!--Navigation Panel--> <A NAME="tex2html110"  HREF="node8.html"> <IMG WIDTH="37" HEIGHT="24" ALIGN="BOTTOM" BORDER="1" ALT="next"  SRC="/usr/lib/latex2html/icons.png/next_motif.png"></A>  <A NAME="tex2html108"  HREF="node3.html"> <IMG WIDTH="26" HEIGHT="24" ALIGN="BOTTOM" BORDER="1" ALT="up"  SRC="/usr/lib/latex2html/icons.png/up_motif.png"></A>  <A NAME="tex2html102"  HREF="node6.html"> <IMG WIDTH="63" HEIGHT="24" ALIGN="BOTTOM" BORDER="1" ALT="previous"  SRC="/usr/lib/latex2html/icons.png/previous_motif.png"></A>    <BR> <B> Next:</B> <A NAME="tex2html111"  HREF="node8.html">data.frame</A> <B> Up:</B> <A NAME="tex2html109"  HREF="node3.html">Principes fondamentaux</A> <B> Previous:</B> <A NAME="tex2html103"  HREF="node6.html">vector</A> <BR> <BR> <!--End of Navigation Panel-->  <H2><A NAME="SECTION00032000000000000000"> matrix</A> </H2>  Cet objet est semblable  la notion mathmatique de matrice. Une matrice peut contenir des valeurs numriques, des caractres ou des boolens, mais tous ses lments doivent tre du mme type.  <P> <TT>&gt; mat1 &lt;- matrix((15:1),nrow=3,ncol=5,byrow=T)</TT> : cre une matrice de 3 lignes sur 5 colonnes contenant les nombres 15  1. L'argument <TT>byrow</TT> indique si la matrice est remplie horizontalement (<TT>byrow=T</TT>) ou verticalement (<TT>byrow=F</TT>, la valeur par dfaut). Affichez mat1 pour voir le rsultat.  <P> <TT>&gt; dim(mat1)</TT> : donne les dimensions de la matrice <TT>mat1</TT>. <BR> <TT>[1] 3 5</TT>  <P> Les lignes <TT>[numligne,]</TT> et les colonnes <TT>[,numcol]</TT> des matrices peuvent tre spcifiquement dsignes : <BR> <TT>&gt; mat1[2,]</TT> <BR> <TT>[1] 10 9 8 7 6</TT> <BR> <TT>&gt; mat[,3]</TT> <BR> <TT>[1] 13 8 3</TT>  <P> Divers commandes sur les matrices:  <P> <TT>&gt; t(mat1)</TT> : donne la transpose de la matrice <TT>mat1</TT>.  <P> <TT>&gt; cbind(mat1[,2],mat1[,4])</TT> : construit une matrice dont les arguments sont les colonnes <TT>2</TT> et <TT>4</TT> de la matrice <TT>mat1</TT>.  <P> <TT>&gt; rbind(mat1[3,],mat1[2])</TT> : construit une matrice dont les arguments sont les lignes <TT>3</TT> et <TT>2</TT> de la matrice <TT>mat1</TT>.  <P> <TT>&gt; colnames() &lt;- list("c1","c2","c3","c4","c5")</TT> : pour associer des noms aux colonnes de la matrice <TT>mat1</TT>.  <P> <TT>&gt; rownames() &lt;- list("l1","l2","l3")</TT> : pour associer des noms aux lignes de la matrice <TT>mat1</TT>.  <P> <HR> <!--Navigation Panel--> <A NAME="tex2html110"  HREF="node8.html"> <IMG WIDTH="37" HEIGHT="24" ALIGN="BOTTOM" BORDER="1" ALT="next"  SRC="/usr/lib/latex2html/icons.png/next_motif.png"></A>  <A NAME="tex2html108"  HREF="node3.html"> <IMG WIDTH="26" HEIGHT="24" ALIGN="BOTTOM" BORDER="1" ALT="up"  SRC="/usr/lib/latex2html/icons.png/up_motif.png"></A>  <A NAME="tex2html102"  HREF="node6.html"> <IMG WIDTH="63" HEIGHT="24" ALIGN="BOTTOM" BORDER="1" ALT="previous"  SRC="/usr/lib/latex2html/icons.png/previous_motif.png"></A>    <BR> <B> Next:</B> <A NAME="tex2html111"  HREF="node8.html">data.frame</A> <B> Up:</B> <A NAME="tex2html109"  HREF="node3.html">Principes fondamentaux</A> <B> Previous:</B> <A NAME="tex2html103"  HREF="node6.html">vector</A> <!--End of Navigation Panel--> <ADDRESS> <I>Pierre Dupont</I> <BR><I>2000-03-07</I> </ADDRESS> </BODY> </HTML> 
