I have a dataset products
like so:
> head(featured_products)
Dept Class Sku Description Code Vehicle/Placement StartDate EndDate Comments(Circulation,Location,etc)
1: 430 4318 401684 ++INDV RAMEKIN WP 9CM OSM Facebook 2017-01-01 2017-01-29 Fancy Brunch Blog
2: 430 4318 401684 ++INDV RAMEKIN WP 9CM OSM Twitter 2017-01-01 2017-01-29 Fancy Brunch Blog
3: 340 3411 1672605 ++ SPHERE WILLOW 4" OP1 Editorial 2016-02-29 2016-03-27 Spruce up for Spring
4: 230 2311 2114074 ++BOX 30 ISLAND ORCHRD TLIGHTS EM Email 2016-02-17 2016-02-17 Island Orchard and Jeweled Lanterns
5: 895 8957 2118072 ++PAPASAN STL TAUPE OSM Instagram 2017-08-26 2017-10-01 by @audriestorme
6: 895 8957 2118072 ++PAPASAN STL TAUPE EM Email 2017-11-23 2017-11-23 Day 2 Black Friday AM
and another dataset sales
like so:
SKU ActivityDate OnlineSalesQuantity OnlineDiscountPercent InStoreSalesQuantity InStoreDiscountPercent
1: 401684 2015-12-01 150 0.00 406 2.72
2: 401684 2015-12-02 0 0.00 556 3.79
3: 401684 2015-12-03 0 0.00 723 3.44
4: 401684 2015-12-04 16 4.91 781 2.46
5: 401684 2015-12-05 17 0.00 982 3.18
6: 401684 2015-12-06 0 0.00 851 3.12
Now...how can I create a flag column in the sales
dataset entitled "featured"? This should be 1 if the ActivityDate
falls between the times listed in products
(StartDate, EndDate) and 0 otherwise...
I have tried several suggested posts on creating intervals out of POSIXct
times but none of them really seem to suit my needs.
Suggestions would be very nice. Thank you.