[R] Isolating Distinct Dates between two data frames

Ogbos Okike g||ted|||e2014 @end|ng |rom gm@||@com
Mon Mar 2 04:10:41 CET 2020


Dear Jim,
Many thanks for sparing your time to assist me.

I have tried your codes. It worked very well to some extent for me. At
least it produced the indices you mentioned.

But I got stuck when I think of how to use it in further calculations
as you indicated. I tried including the indices as the first column of
the data. I did the same for each of the station data. That is
including the length (example 1:1609) as the first column. But that
brought me back to the original problem as I had no means of isolating
the uncommon dates using the common dates selected for the two
stations.

I guess that you can point me further to the right direction to use
the indices to discriminate between common dates and uncommon dates
and their associated V2 (Forbush events).

Warm regards
Ogbos

On Sun, Mar 1, 2020 at 10:49 PM Jim Lemon <drjimlemon using gmail.com> wrote:
>
> Hi Ogbos,
> One way to get all combinations of common and different dates is:
>
> THULinINVK<-which(THUL1$V1 %in% INVK1$V1)
> THULnotinINVK<-which(!(THUL1$V1 %in% INVK1$V1))
> INVKinTHUL<-which(INVK1$V1 %in% THUL1$V1)
> INVKnotinTHUL<-which(!(INVK1$V1 %in% THUL1$V1))
>
> This produces vectors of indices that can be used in further calculations.
>
> Jim
>
> On Mon, Mar 2, 2020 at 8:12 AM Ogbos Okike <giftedlife2014 using gmail.com> wrote:
> >
> > Dear Friends,
> > I have two data frame of the form:
> > 1997-11-2219 -2.54910135429339
> > 1997-11-2222 -2.66865640466636
> > 1997-11-2305 -2.60761691358946
> > 1997-12-1104 -2.5323738405159
> > 1997-12-1106 -2.6020470080341
> > 1998-05-0204 -4.49745020062937
> > 1998-05-0209 -4.9462725263541
> > 1998-05-0213 -4.60533021405541
> > 1998-05-0218 -4.24415210827579
> > 1998-05-0220 -4.04368079911755
> > 1998-05-0222 -4.05320945184028
> > 1998-05-0302 -4.97226664313875
> > 1998-05-0307 -3.59108791877756
> > 1998-05-0310 -4.06038057061717
> > 1998-05-0313 -4.25967313751507
> > 1998-05-0316 -3.51896561964782
> > 1998-05-0318 -3.43849389406503
> > 1998-05-0321 -2.85778623531446
> > 1998-05-0323 -2.75731441597261
> > 1998-05-0401 -2.85684255921844
> > 1998-05-0403 -2.69637066510405
> > 1998-05-0408 -4.47519076670884
> > 1998-05-0411 -4.2644827160855
> > 1998-05-0414 -4.20377458198688
> > 1998-05-0417 -4.27306636458818
> > 1998-05-0420 -4.05235806406442
> > 1998-05-0500 -4.19141353436269
> > 1998-05-0506 -4.23999646421515
> > 1998-05-0510 -3.95905156765632
> > 1998-05-0512 -3.63857906459363
> >
> > and
> > 1997-11-2221 -2.04916867404692
> > 1997-11-2303 -1.7285761175751
> > 1998-04-3010 -1.51968127380408
> > 1998-04-3016 -1.51845077174125
> > 1998-05-0101 -1.91660416876407
> > 1998-05-0104 -2.11598840871961
> > 1998-05-0107 -1.99537253619755
> > 1998-05-0109 -1.81496189214167
> > 1998-05-0112 -1.7343458326657
> > 1998-05-0114 -1.77393506418581
> > 1998-05-0121 -1.57249698394961
> > 1998-05-0204 -3.64105829839415
> > 1998-05-0207 -3.5504415342881
> > 1998-05-0209 -3.71003029685917
> > 1998-05-0213 -3.31920767504605
> > 1998-05-0219 -3.98797337595274
> > 1998-05-0300 -3.17694445869443
> > 1998-05-0304 -3.09612110658432
> > 1998-05-0306 -3.29570935794719
> > 1998-05-0308 -3.24529756101203
> > 1998-05-0310 -3.20488571584633
> > 1998-05-0312 -3.16447382251761
> > 1998-05-0314 -2.86406188109331
> > 1998-05-0319 -2.5430318175571
> > 1998-05-0321 -2.87261970832946
> > 1998-05-0400 -2.55200145489882
> > 1998-05-0407 -3.27055844665711
> > 1998-05-0409 -3.24014605168738
> > 1998-05-0412 -3.29952737040137
> > 1998-05-0414 -3.44911485708791
> >
> > Some dates are common among the two.
> >
> > I use few  lines of code to select the common dates:
> > setwd("./")
> >  list1<-read.table("THUL1",col.names=c("V1","V2"))
> >  list2<-read.table("INVK1",col.names=c("V1","V2"))
> >  B<-merge(list1,list2, by ="V1")
> >
> > Now, I wish to do something differently. I want to identify the dates that
> > are in THUL1 but are not in INVK1 or vise versa, that is to identify
> > uncommon dates among the two lists.
> >
> > Could you please assist me to achieve it.
> >
> > Thank you.
> > Best regards
> > Ogbos
> >
> >         [[alternative HTML version deleted]]
> >
> > ______________________________________________
> > R-help using r-project.org mailing list -- To UNSUBSCRIBE and more, see
> > https://stat.ethz.ch/mailman/listinfo/r-help
> > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> > and provide commented, minimal, self-contained, reproducible code.



More information about the R-help mailing list