如何在R中使用Excel拖动功能

时间:2018-06-28 07:46:47

标签: r

我有一些数据,我想在上一行的前面的值中填充值。该功能类似于我们在EXCEL中所做的操作,我们拖动值,黑色行将被填充。我有类似的1000个此类带有值的行,并且在该值以下有空白列

我尝试了

rep() 

R的功能,但对我不起作用!

输入

>dput(Trail)

structure(list(V1 = c("ABCD", NA, NA, NA, "EFGH", NA, NA, "IJKLS"
), V2 = c(0.5, NA, NA, NA, 1.3, NA, NA, 1.4), V3 = c(0.6, NA, 
NA, NA, 0.4, NA, NA, 9.4), V4 = c(10, NA, NA, NA, 11, NA, NA, 
10), V5 = c(11, NA, NA, NA, 0.5, NA, NA, 11), V6 = c("A", "B", 
"C", "E", "F", "G", "H", "I")), row.names = c(NA, -8L), class = c("tbl_df", 
"tbl", "data.frame"))

输出

structure(list(V1 = c("ABCD", "ABCD", "ABCD", "ABCD", "EFGH", 
"EFGH", "EFGH", "IJKLS"), V2 = c(0.5, 0.5, 0.5, 0.5, 1.3, 1.3, 
1.3, 1.4), V3 = c(0.6, 0.6, 0.6, 0.6, 0.4, 0.4, 0.4, 9.4), V4 = c(10, 
10, 10, 10, 11, 11, 11, 10), V5 = c(11, 11, 11, 11, 0.5, 0.5, 
0.5, 11), V6 = c("A", "B", "C", "E", "F", "G", "H", "I")), row.names = 
c(NA,-8L), class = c("tbl_df", "tbl", "data.frame"))

0 个答案:

没有答案