[R] Reading Data
Rahul-A.Agarwal at ubs.com
Rahul-A.Agarwal at ubs.com
Tue Oct 7 12:33:07 CEST 2008
Why m I getting this message
data=read.table("H:/Rahul/london/david/rexcel/price1.txt",header=T,check.names=F,row.names=1)
Error in read.table("H:/Rahul/london/david/rexcel/price1.txt", header = T, :
duplicate 'row.names' are not allowed
Rahul Agarwal
Analyst
Equities Quantitative Research
UBS_ISC, Hyderabad
On Net: 19 533 6363
-----Original Message-----
From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org] On Behalf Of Philipp Pagel
Sent: Tuesday, October 07, 2008 2:52 PM
To: r-help at r-project.org
Subject: Re: [R] Reading Data
> 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
______________________________________________
R-help at r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
More information about the R-help
mailing list