I have a big dataframe that I want to fill in with results from SQL queries to many databases, so kind of "filling in data cubbyholes" so to speak. Wrinkle: I don't know how many cubbyholes will be filled in (there's a group_by year, so I might get a dataframe with one year, or many).
I'm having difficulty figuring out how to accomplish this. I'm trying to use the dplyr package..
left_join either adds the same row twice (if I specify the
by=), or drops the new column (if I don't specify the
by= and thus it joins on both similar columns)
bind_cols doesn't work
bind_rows adds a duplicate row.
How can I get the new data to fill in the cubbyhole itself? (btw, I'm not married to dplyr... I just don't want to iterate through every element of the new dataframe)
TargetDF <- structure(list(Ind = c(5, 6, 7), `2015 Act` = c(7870L, NA, NA
)), .Names = c("Ind", "2015 Act"), class = c("tbl_df", "data.frame"
), row.names = c(NA, -3L))
tempDF <- structure(list(Ind = 6, `2015 Act` = 49782L, `2016 Act` = 323L), .Names = c("Ind",
"2015 Act", "2016 Act"), class = c("tbl_df", "tbl", "data.frame"