You can do everything with base
functions. The trick is to use indexing by a 2-col (row and col indices) matrix:
j <- f$row
i <- cumsum(j == 1)
x <- f$value
m <- matrix(NA, max(i), max(j))
m[cbind(i, j)] <- x
m
Whether it is better or not than using the Matrix
package is subjective. Overkill in my opinion if you are not doing anything else with it. Also if your data had 0
in the f$value column, they would end up being converted as NA
if you are not too careful.