[R] Converting data from weekly interval to daily interval

Greg Minshall m|n@h@|| @end|ng |rom um|ch@edu
Wed Jun 9 04:30:43 CEST 2021


Bhaskar,

not your main question, but ...

given that you have column names, you might think of

:     df2[inc,"date"] <- df1[i,"date"]/7
or
:     df2[inc,]$date <- df1[i,]$date/7

i.e., using your column names instead of numeric indices.

then, also, instead of a for loop, possibly you can use R's nicely
vectorized operations.  i.e., something like

: df2$date <- df2$date/7

nb: i haven't tried to run the above code, so no guarantees.

(again, if i've typed that correctly -- i haven't tested -- you will end
up with the same answers you *don't* want, but maybe more
idiomatically.)

cheers, Greg



More information about the R-help mailing list