It is my effort to restore the question that appeared yesterday, and which I worked most of the morning to resolve, but can no longer find the question. The 2 datasets, df1 and smaller df2, were provided with the same column names with a query to replace only the NA values ββin the rows where the column datematched. I suppose a merger could do this, and perhaps be less burdensome, but I was looking for an match()indexing and indexing strategy and eventually found it:
df1 <- structure(list(date = c(20040101L, 20040115L, 20040131L, 20040205L,
20040228L, 20040301L, 20040315L, 20040331L), X11A = c(100L, 200L,
NA, NA, NA, 150L, NA, NA), X11A.1 = c(150L, NA, 165L, NA, NA,
155L, NA, NA), X21B = c(NA, 200L, 180L, NA, NA, 170L, 180L, NA
), X3CC = c(NA, NA, 190L, NA, NA, 150L, 190L, 175L), X3CC.1 = c(140L,
NA, 190L, NA, NA, 160L, 200L, 180L)), .Names = c("date", "X11A",
"X11A.1", "X21B", "X3CC", "X3CC.1"), class = "data.frame", row.names = c(NA,
-8L))
df2 <- structure(list(date = c(20040228L, 20040131L, 20040331L), X11A = c(140L,
170L, NA), X11A.1 = c(145L, NA, 145L), X21B = c(165L, NA, 160L
), X3CC = c(150L, NA, NA), X3CC.1 = c(155L, NA, NA)), .Names = c("date",
"X11A", "X11A.1", "X21B", "X3CC", "X3CC.1"), class = "data.frame", row.names = c(NA,
-3L))
What was really proposed:
df1:
date 11A 11A 21B 3CC 3CC
20040101 100 150 NA NA 140
20040115 200 NA 200 NA NA
20040131 NA 165 180 190 190
20040205 NA NA NA NA NA
20040228 NA NA NA NA NA
20040301 150 155 170 150 160
20040315 NA NA 180 190 200
20040331 NA NA NA 175 180
df2:
date 11A 11A 21B 3CC 3CC
20040228 140 145 165 150 155
20040131 170 NA NA NA NA
20040331 NA 145 160 NA NA