below data set.
structure(list(sap_no = c(NA, 1910109125, 1910106937, 1910110360,
1910110108, 1910107512, 1910108668, 1910108923, 1910110338, 1910110591
), qty = c(2, 1, 2, 1, 5, 1, 2, 1, 2, 2), date = structure(c(18001,
18001, 18002, 18002, 18002, 18003, 18003, 18009, 18010, 18016
), class = "Date")), row.names = c(NA, -10L), class = c("tbl_df",
"tbl", "data.frame"))
I tried to select date
clean_backorder$date<-as.Date(clean_backorder$date, origin = "1899-12-30")
with(clean_backorder,clean_backorder[date >= "2019-01-01" & date<="2019-12-31"])
it gave me error
Error in `vectbl_as_col_location()`:
! Must subset columns with a valid subscript vector.
ℹ Logical subscripts must match the size of the indexed input.
x Input has size 3 but subscript `date >= "2019-01-01" & date <= "2019-12-31"` has size 1525.
how can I fix this pls? btw when I run head function to the data frame, it looks like the date column is in date format?
> head(clean_backorder$date,10)
[1] "2019-04-15" "2019-04-15" "2019-04-16" "2019-04-16" "2019-04-16" "2019-04-17" "2019-04-17" "2019-04-23"
[9] "2019-04-24" "2019-04-30"