Hi:

Perhaps something like this, assuming DATE is a Date object (try str(plcm60)
to check) - if not, you need to use as.Date() to convert.

jandays <- data.frame(DATE = seq(as.Date('2003-01-01'), by = 'days', length
= 23))
merge(jandays, plcm60, by = 'DATE', all.x = TRUE)

HTH,
Dennis

On Wed, Nov 24, 2010 at 5:58 PM, Jagdish Gangolly
<gangolly@csc.albany.edu>wrote:

> I have a stock price dataset  a snippet of which is:
>
> > plcm60[1:15, c(1,3,4,5,6,7)]
>     DATE  BIDLO ASKHI    PRC     VOL       RET
> 1   1/2/03  9.450  9.79  9.700 1531819  0.018907
> 2   1/3/03  9.670  9.94  9.940 1582192  0.024742
> 3   1/6/03  9.830 10.05  9.960 1843298  0.002012
> 4   1/7/03  9.835 10.38 10.350 1412441  0.039157
> 5   1/8/03 10.220 10.67 10.260  961400 -0.008696
> 6   1/9/03 10.280 11.05 11.020 1742989  0.074074
> 7  1/10/03 10.900 11.29 11.100  701203  0.007260
> 8  1/13/03 11.150 11.44 11.350  959718  0.022523
> 9  1/14/03 11.130 11.40 11.230  994991 -0.010573
> 10 1/15/03 11.110 11.73 11.410 1678751  0.016029
> 11 1/16/03 10.850 11.40 11.079  887901 -0.029010
> 12 1/17/03 10.560 10.91 10.710  968015 -0.033306
> 13 1/21/03 10.430 10.76 10.680  747969 -0.002801
> 14 1/22/03 10.510 10.82 10.560 2702355 -0.011236
> 15 1/23/03 10.700 11.95 11.910 2262855  0.127841
>
> Since the market is closed saturdays, sundays and holidays,
> the dataset has gaps. I need to insert rows (with dates
> but all other columns blank) so that the date
> column in the dataset will have all dates on the calendar?
>
> Is there a simple solution using only strptime, and for loops?
>
> Jagdish
>
> ______________________________________________
> 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.
>

	[[alternative HTML version deleted]]

