[R] reading a file

Steve Lianoglou mailinglist.honeypot at gmail.com
Thu Jul 30 15:27:18 CEST 2009


Hi,

On Jul 30, 2009, at 9:08 AM, Mohsen Jafarikia wrote:

> Hello there,
> I have the following info in MyData:
>
> 01          0.40
> 02          0.40
> 03          0.40
> 04          0.35
> 05          0.34
> 06          0.33
>
> I want to read them using the following code:
>
> ifn <- "MyData"
> dat <- read.table(ifn)
>
> names(dat1)<-c("Code","M")
> names(dat2)<-c("Code","M")
>
> I want to have the first three lines in dat1 and second three lines  
> in dat2.
> Any one can help on this please.

Just split your data file in two after you read it:

dat1 <- dat[1:3,]
dat2 <- dat[4:6,]

-steve

--
Steve Lianoglou
Graduate Student: Computational Systems Biology
   |  Memorial Sloan-Kettering Cancer Center
   |  Weill Medical College of Cornell University
Contact Info: http://cbio.mskcc.org/~lianos/contact




More information about the R-help mailing list