Hi What if I need to take dates and stock names from these table...i mean I need to read in this table and then use if function and extratc the data from FOO Identifier weight Start_Date End_Date a 6.76 31Jan06 31Jan07 g 2.86 28Feb06 28Feb07 e 22.94 31Mar06 30Mar07 c 30.05 28Apr06 30Apr07 t 20.55 31May06 31May07
Rahul Agarwal Analyst Equities Quantitative Research UBS_ISC, Hyderabad On Net: 19 533 6363 -----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Philipp Pagel Sent: Tuesday, October 07, 2008 2:52 PM To: r-help@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@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. ______________________________________________ R-help@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.