- 795 名前:132人目の素数さん mailto:sage [2013/03/14(木) 09:59:33.96 ]
- >>793
単純にコピーするだけでは駄目なの? > sample <- data.frame(matrix(c("AAA1","Apple",1,100,10, + "","","",98,12, + "","","",102,8, + "AAA2","Orange",2,120,3, + "","","",130,4, + "","","",112,8), ncol = 5, byrow = TRUE)) > names(sample) <- c("ID", "NAME", "MONTH", "PRICE", "NUMBER") > sample ID NAME MONTH PRICE NUMBER 1 AAA1 Apple 1 100 10 2 98 12 3 102 8 4 AAA2 Orange 2 120 3 5 130 4 6 112 8 > for(i in 1:(nrow(sample) - 1)){ + if(sample[i+1, 1] == ""){ + sample[i+1, 1:3] <- sample[i, 1:3] + } + } > sample ID NAME MONTH PRICE NUMBER 1 AAA1 Apple 1 100 10 2 AAA1 Apple 1 98 12 3 AAA1 Apple 1 102 8 4 AAA2 Orange 2 120 3 5 AAA2 Orange 2 130 4 6 AAA2 Orange 2 112 8
|

|