0

I have two data set here. One is here like this.

>sp2
# A tibble: 1,822 x 3
         Date  Hour  Price
       <dttm> <chr>  <dbl>
 1 2015-12-31     2  17.15
 2 2015-12-30     2  26.23
 3 2015-12-29     2  23.01
 4 2015-12-28     2  20.58
 5 2015-12-27     2  14.09
 6 2015-12-26     2 -66.02
 7 2015-12-25     2  -4.50
 8 2015-12-24     2  18.32
 9 2015-12-23     2   0.43
10 2015-12-22     2 -81.04
# ... with 1,812 more rows

The other data I have is as below:

> head(da2)
   LiefertagDeliveryDate Price Hour
1:            2015-12-31 22.73    2
2:            2015-12-30 32.30    2
3:            2015-12-29 43.38    2
4:            2015-12-28 48.03    2
5:            2015-12-27 45.08    2
6:            2015-12-26 25.50    2

Thing is, the sp2 has 1822 observations and da2 has 1826 observations. I want to find out what are the 4 observations discrepancy and what are the info of those 4 observations. People suggested me to use setdiff. But When I used it, it showed just weird numbers like

[1] 1451520000 1451433600 1451347200 1451260800 1451174400 1451088000 1451001600 1450915200 1450828800 1450742400 1450656000 1450569600 1450483200 1450396800
[15] 1450310400 1450224000 1450137600 1450051200 1449964800 1449878400 1449792000 1449705600 1449619200 1449532800 1449446400 1449360000 1449273600 1449187200

I do not know what the problem is. Is it maybe because date of sp2 property is not "Date"? It shows like this:

class(sp2$Date)
[1] "POSIXct" "POSIXt"

I really do not know what is problem. I can send my data to people but I do not know how to send since I just joined the community.

nicola
  • 24,005
  • 3
  • 35
  • 56
S. Jay
  • 141
  • 2
  • 10
  • Did you try `da2[!da2[['LiefertagDeliveryDate']] %in% sp2[['Date']], ]` ? – Deena Jan 03 '18 at 13:23
  • 1
    Please use `dput` to provide a sample of your data. – Tino Jan 03 '18 at 13:23
  • Yes. It shows me stuff but I do not think it is what I want. – S. Jay Jan 03 '18 at 13:25
  • Please note the **Details** section of `?setdiff`: "`setdiff` [...] appl[ies] `as.vector` to their arguments". Check `class(Sys.time())` and `class(as.vector(Sys.time()))`. – Henrik Jan 03 '18 at 13:42

0 Answers0