Message-ID: <x2el2yikhh.fsf@biostat.ku.dk>
Date: 2003-05-16T22:34:37Z
From: Peter Dalgaard
Subject: Newbie Matrix problem refined; Can't convert .csv data to matrix
In-Reply-To: <NDEKIJPPGJCIKBNEDOKOEEAOCCAA.rwatkins@cornerstonelp.com>
<rwatkins at cornerstonelp.com> writes:
> Thanks to all for your previous help. I see now that my problem is
> converting my .csv file of data into a matrix. My example is a (3x3) matrix
> with a "header" row (that doesn't contain numerics).
>
> Thanks again for your time and gracious consideration.
I believe that was actually answered in at least one of the replies
you already got, but to reiterate: Use as.matrix to coerce the data
frame returned by read.csv to a matrix. As in:
> A <- as.matrix(read.csv(stdin()))
0: A,B,C
1: 1,2,3
2: 4,5,6
3: 7,8,9
4:
> A%*%A
A B C
1 30 36 42
2 66 81 96
3 102 126 150
--
O__ ---- Peter Dalgaard Blegdamsvej 3
c/ /'_ --- Dept. of Biostatistics 2200 Cph. N
(*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918
~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk) FAX: (+45) 35327907