# Calculate 7day realized volatility each week for Dataframe with daily log returns

I have a dataframe consisting of daily log returns for multiple time series. I want to calculate the 7-day realized volatility for each time series column for every week. Is there a fast way to get this done? For example if I have 70 observations, I would get 10 realized volatility results. So for every week. Your help is much appreciated.

I tried multiple solutions suggested here but could not figure it out. Many thanks!

MyData looks as follows:

structure(list(timestamp = structure(list(sec = c(59, 59, 59, 59, 59, 59, 59, 59, 59, 59), min = c(59L, 59L, 59L, 59L, 59L, 59L, 59L, 59L, 59L, 59L), hour = c(23L, 23L, 23L, 23L, 23L, 23L, 23L, 23L, 23L, 23L), mday = 1:10, mon = c(0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L), year = c(118L, 118L, 118L, 118L, 118L, 118L, 118L, 118L, 118L, 118L), wday = c(1L, 2L, 3L, 4L, 5L, 6L, 0L, 1L, 2L, 3L), yday = 0:9, isdst = c(0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L), zone = c("CET", "CET", "CET", "CET", "CET", "CET", "CET", "CET", "CET", "CET"), gmtoff = c(NA_integer_, NA_integer_, NA_integer_, NA_integer_, NA_integer_, NA_integer_, NA_integer_, NA_integer_, NA_integer_, NA_integer_)), class = c("POSIXlt", "POSIXt"), tzone = ""), ADA = c(0.00519787736925448, 0.0307208647325365, 0.154138771350992, 0.0164342066551776, -0.0557120045069119, 0.0137042340758324, -0.00923274693800846, -0.0560696427736868, -0.0453846430358594, -0.0119861841881651), BNB = c(-0.0231997754459639, 0.0439663779991935, 0.0685574769535244, -0.0310282134011945, 0.443641921228532, 0.400594784041669, -0.189571775497508, -0.0203461395784901, -0.0450853757768916, -0.00114121883972107), BTC = c(-0.0358973950143717, 0.0925827850343683, 0.0145041249453595, 0.025856749062152, 0.110937798087752, 0.00557805699941127, -0.0617370565817161, -0.082670269191885, -0.0386173267907015, 0.0255604355626176)), row.names = c(NA, 10L), class = "data.frame")

• There's more than 7 weeks in 70 days? Anyway, your data is missing the date(time) column. Commented Jul 12, 2022 at 7:08
• I edited my post. Ty for the info! Commented Jul 12, 2022 at 7:27