Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- df1 df2
- Geogkey Brand Week date Impressions
- TMZ43434 x 6/16/18 6/14/18 798798
- KRO36783 y 6/16/18 6/21/18 562314
- .... 6/28/18 462534
- n
- Geogkey date Impressions
- TMZ43434 6/14/18 798798
- TMZ43434 6/21/18 562314
- TMZ43434 6/28/18 462534
- KRO36783 6/14/18 798798
- KRO36783 6/21/18 562314
- KRO36783 6/28/18 462534
- empty <- data.frame(df2$date, df2$impressions)
- #creates a new data frame with unique geogkeys
- geogname <- unique(data.frame(df1$GEOGKEY))
- #create some function that will index each unique geogkey and make a new
- column for df2 with that name (e.g. df2$geogkey <- some function)
- new_df <- rbind(empty, df2)
- #this should theoretically append all the geogkeys to the dates and
- impressions
- df <- data.frame()
- for(i in unique(df1$GEOKEY){
- for(j in 1:nrow(df2)){
- df <- rbind(df,
- data.frame('key' = i, 'date' = df2[j,1], 'impressions' = df2[j,2]))
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement