You could directly assign the values by using []
(您可以使用[]
直接分配值)
df1[] <- df2[1, ]
df1
# col1 col2 col3
#1 1 2 5
#2 1 2 5
#3 1 2 5
#4 1 2 5
#5 1 2 5
data
(数据)
df1 <- data.frame(col1 = 1:5, col2 = 2:6, col3 = 3:7)
df2 <- data.frame(col1 = 1:3, col2 = 2:4, col3 = 5:7)
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…