The answer is vectorization:
data[,2] = 2
data[,3] = 3
finishes instantly for me. For loops in interpreted languages like R are veeeeery slow. Performing this kind of operation by assigning a vector directly (i.e. vectorized) is much, much faster.
Programming in a new language requires a new mindset. Your approach breathes a compiled language, no need for the for loop.