Try this:
# Initialize a testing matrix
(m <- matrix(1:12, 3, 4))
[,1] [,2] [,3] [,4]
[1,] 1 4 7 10
[2,] 2 5 8 11
[3,] 3 6 9 12
# Calculate cumulative average by column for each row
t(apply(m, 1, cumsum) / seq(ncol(m)))
[,1] [,2] [,3] [,4]
[1,] 1 2.5 4 5.5
[2,] 2 3.5 5 6.5
[3,] 3 4.5 6 7.5
This essentially takes the row-wise cumulative summation, then divides by a recycled array indicating the column index.
Edit: In case you're doing something similar with data frames, this approach using data.table and reshape2 packages could be useful:
library(data.table)
dt <- data.table(m)
# Add row number to melt by
dt[, row := seq(nrow(dt))]
library(reshape2)
dt.molten <- data.table(melt(dt, "row"))
# Row-level format
dt.molten[, cumsum(value) / as.numeric(variable), "row"]
row V1
1: 1 1.0
2: 1 2.5
3: 1 4.0
4: 1 5.5
5: 2 2.0
6: 2 3.5
7: 2 5.0
8: 2 6.5
9: 3 3.0
10: 3 4.5
11: 3 6.0
12: 3 7.5