I'm not quite sure I understand what you want but I'll give it a try.
If the data in fields F1-F6 are numeric (and I'm assuming that the
"|"
entries in the data field represent dates that are actually repeated in
the real data file), then read.data() is the right way to start. If you
then want to do numeric/matrix operations, you could try turning just the
numeric columns into a matrix: for example
z <- read.data("mydata")
z.num <- as.matrix(z[,3:8]) ## take just columns 3 to 8
OR
z.num <- as.matrix(z[,-(1:2)]) ## drop just columns 1 and 2
You could also try
z.list <- lapply(split(1:nrow(z),z$device),function(r)x[,r])
to split your numeric matrix into a list organized by device.
"split(1:nrow(z),z$device)" makes a list of the row numbers in the
data
associated with each device; the "lapply" command then replaces each
of
the sets of row numbers with the actual rows of data. (You can then use
"lapply" on this list to calculate means, etc. for each device.)
good luck,
Ben
On Fri, 7 Apr 2000, TRAN Liem FTM/Men wrote:
> Hello everybody,
>
> I'm a new R user and I've got some difficulties to find the right
way to
> read data files.
>
> My problem is the following:
>
> I have dayly records of different devices (they all have their own name)
> during a time period (let's say one year). Each device records 6
fields.
>
> I would like to consider that one "fellow" is the recording of
one to
> six fields for one
> device during the time period.
> So my data files have the following format (F = field):
>
> date device F1 F2 F3 F4 F5 F6
> 01/01/99 name1 x y z a a b
> | name1 s d g g n r
> | name1 e z a t p m
> 31/12/99 name1 f g h t e b
> 01/01/99 name2 zz ww xx gg gg h
> | name2 aa qq dy ff gr k
> | name2 mr ty t te m a
> 31/12/99 name2 az er rr e l m
>
> and so on for 40 device.
>
> I would like to keep the link beetween each type of record and the name
> device.
>
> If I use read.table, the two first columns are loaded but I can't make
> basic operation on matrices because the following error appears:
> >Warning messages:
> >1: NAs introduced by coercion
> >2: NAs introduced by coercion
>
> My basic questions are then: How can I keep the link beetwen name device
> (character) (with date ifpossible) and the recorded fields (numeric)?
> What is the command to use for reading this file format and use basic
> functions on matrices (i.e, calculus will not take care about nor names,
> neither dates)
>
> I hope my explanation is clear.
>
> Sorry for disturbing and many thanks in advance for any help
>
> Liêm TRAN
>
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
> r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
> Send "info", "help", or "[un]subscribe"
> (in the "body", not the subject !) To: r-help-request at
stat.math.ethz.ch
>
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
>
>
--
Ben Bolker bolker at zoo.ufl.edu
Zoology Department, University of Florida http://www.zoo.ufl.edu/bolker
318 Carr Hall/Box 118525 tel: (352) 392-5697
Gainesville, FL 32611-8525 fax: (352) 392-3704
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !) To: r-help-request at
stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._