[R] Newbie hung up with matrices

Prof Brian Ripley ripley at stats.ox.ac.uk
Fri May 16 20:32:18 CEST 2003

On Fri, 16 May 2003 rwatkins at cornerstonelp.com wrote:

> 	I just started learning R.  I'm trying to use the Help and the downloadable
> manuals.  I am stuck on trying to multiply matrices.  Can anyone please
> supply a couple of lines of code that I can plug into a fresh console to see
> how  a double precision (1x3) matrix is multiplied by a double precision
> (3x3) matrix?  I keep getting an error message,"Error in x%*%A: requires
> numeric matrix/vector arguments".
> 	I have some VBA and VB experience (thus a little Object Oriented
> programming experience), am I right in beliving that I am not "dimensioning"
> correctly?  I have been trying the following example:
> 		A<-matrix
> 		A<-read.csv("test33.csv"), where the data is
> 				A,B,C
> 				1,4,7
> 				2,5,8
> 				3,6,9

You've forgotten header=TRUE, if you don't want A,B,C to be part of your 
matrix.  R comes with a Data Import/Export Manual: please consult it.

Brian D. Ripley,                  ripley at stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595

More information about the R-help mailing list