You can use base-R syntax:
df1[] <- df1$V3
df2 <- copy(df1)
df2[] <- df1$V3
I think most data.table-ish is the way to change so many columns with set:
for (j in setdiff(names(df1),"V3")) set(df1, j = j, value = df1$V3)
Finally, there are a few other good ideas from @akrun, @DavidArenburg and @VeerendraGadekar:
df1[, (1:ncol(df1)) := V3]
df2 <- setDT(rep(list(df1$V3), ncol(df1)))
df2 <- df1[, rep("V3",ncol(df1)), with = FALSE]
Frank source
share