[R] Newbie hung up with matrices

Marc Feldesman feldesmanm at pdx.edu
Fri May 16 20:38:37 CEST 2003


On Fri, 16 May 2003 12:00:42 -0500, an incredible array of electrons
randomly cascading around the Universe collided and turned into words
spewed forth by rwatkins at cornerstonelp.com:


rwatkins at cornerstonelp.com> Hi all:
rwatkins at cornerstonelp.com> 	Thanks in advance for your assistance.
rwatkins at cornerstonelp.com> 
rwatkins at cornerstonelp.com> 	I just started learning R.  I'm trying
to use the Help and the downloadable
rwatkins at cornerstonelp.com> manuals.  I am stuck on trying to multiply
matrices.  Can anyone please
rwatkins at cornerstonelp.com> supply a couple of lines of code that I
can plug into a fresh console to see
rwatkins at cornerstonelp.com> how  a double precision (1x3) matrix is
multiplied by a double precision
rwatkins at cornerstonelp.com> (3x3) matrix?  I keep getting an error
message,"Error in x%*%A: requires
rwatkins at cornerstonelp.com> numeric matrix/vector arguments".
rwatkins at cornerstonelp.com> 
rwatkins at cornerstonelp.com> 	I have some VBA and VB experience
(thus a little Object Oriented
rwatkins at cornerstonelp.com> programming experience), am I right in
beliving that I am not "dimensioning"
rwatkins at cornerstonelp.com> correctly?  I have been trying the
following example:
rwatkins at cornerstonelp.com> 		A<-matrix
rwatkins at cornerstonelp.com> 		A<-read.csv("test33.csv"), where the
data is
rwatkins at cornerstonelp.com> 				A,B,C
rwatkins at cornerstonelp.com> 				1,4,7
rwatkins at cornerstonelp.com> 				2,5,8
rwatkins at cornerstonelp.com> 				3,6,9
rwatkins at cornerstonelp.com> 
rwatkins at cornerstonelp.com> 		x<-c(4,5,6)
rwatkins at cornerstonelp.com> 		x%*%A
rwatkins at cornerstonelp.com> 			ERROR (as shown above)
rwatkins at cornerstonelp.com> 
rwatkins at cornerstonelp.com> 	ALSO, I have downloaded the RExcel
add-in, but have not found any reference
rwatkins at cornerstonelp.com> manual, etc that describes how to use it. 
Any suggestions here are
rwatkins at cornerstonelp.com> appreciated, as I primarily do my work in
Excel.
rwatkins at cornerstonelp.com> 
rwatkins at cornerstonelp.com> 	Are there any good books available
"that will help me in my quest to become
rwatkins at cornerstonelp.com> a more adept user of R?  I know I am going
to need this package for
rwatkins at cornerstonelp.com> multivariate regressions, etc.
rwatkins at cornerstonelp.com> 
rwatkins at cornerstonelp.com> 	Again, thanks in advance for your time
and consideration.
rwatkins at cornerstonelp.com> 
rwatkins at cornerstonelp.com>
______________________________________________


Couple of thoughts.

A<-matrix      # what's the purpose???

A<-read.csv("test33.csv", header=TRUE)

A  # just to list your data

and to make sure that A,B,C aren't stuck in there as rows.

Then your command should work (also assuming that you really have
a CSV file).  Try ?read.csv

Hope this helps.




More information about the R-help mailing list