Myriam Abramson <mabramso at gmu.edu> writes:
> Hi!
>
> I would like to read data read with read.table row by row into a
> c() vector.
>
> data<-read.table("test",header=FALSE)
> for (i in 1:length(data[[1]])) {
> temp <- ??
> do something with temp
> }
>
> data[1,] gives me
> V1 V2 V3 V4 V5
> 1 1 -1 -1 -1 0.33
>
> c[temp[1],temp[2]) gives me
> $V1
> [1] 1
>
> $V2
> [1] -1
>
>
> Sorry if that's well known but I can't still figure it out.
Data frames are essentially lists of variables, and a row of a data
frame is a list as well (it must be able to hold values of different
modes). To turn it into a vector, you can use unlist():
data(airquality)
c(airquality[1,])
unlist(airquality[1,])
or, same effect:
c(airquality[1,], recursive=TRUE)
--
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
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._