[R] Reading Data

Philipp Pagel p.pagel at wzw.tum.de
Tue Oct 7 11:22:04 CEST 2008


> For example
> 
> Stocks	 30-Jan-08	 28-Feb-08	 31-Mar-08	 30-Apr-08	
> a	 1.00	 3.00	 7.00	 3.00	
> b	 2.00	 4.00	 4.00	 7.00	
> c	 3.00	 8.00	 655.00	 3.00	
> d	 4.00	 23.00	 4.00	 5.00	
> e	 5.00	 78.00	 6.00	 5.00	

OK - this may be what you want:

> foo <- read.table('q.tbl', header=T, check.names=F, row.names=1)
> str(foo)
'data.frame':   5 obs. of  4 variables:
 $ 30-Jan-08: num  1 2 3 4 5
 $ 28-Feb-08: num  3 4 8 23 78
 $ 31-Mar-08: num  7 4 655 4 6
 $ 30-Apr-08: num  3 7 3 5 5
> foo
  30-Jan-08 28-Feb-08 31-Mar-08 30-Apr-08
a         1         3         7         3
b         2         4         4         7
c         3         8       655         3
d         4        23         4         5
e         5        78         6         5
> foo['31-Mar-08']
  31-Mar-08
a         7
b         4
c       655
d         4
e         6
> foo['d', '31-Mar-08']
[1] 4

Maybe row.names is not what you want - but the example sould get you going.

cu
	Philipp

-- 
Dr. Philipp Pagel
Lehrstuhl für Genomorientierte Bioinformatik
Technische Universität München
Wissenschaftszentrum Weihenstephan
85350 Freising, Germany
http://mips.gsf.de/staff/pagel



More information about the R-help mailing list