[R] Extracting a subset from a dataframe

2007-02-22 Thread Augusto.Sanabria
Good day everyone,

Can anyone suggest an effective method to solve
the following problem:

I have 2 dataframes D1 and D2 as follows:

D1:
dates   ws   wc pwc
 2005-10-19:12:00  10.8  80  81
 2005-10-20:12:00  12.3   5  15
 2005-10-21:15:00  12.3   3  15
 2005-10-22:15:00  11.3  13  95
 2005-10-23:12:00  12.3  13   2
 2005-10-24:15:00  10.3   2  95
 2005-10-25:15:00  10.3   2   2

D2:
dates   ws   wc  pwc
 2005-02-02:15:00  17.5   5  96
 2005-02-19:15:00  20.1  15  97
 2005-02-20:18:00  16.5  95  95
 2005-03-03:18:00  10.3  95  95
 2005-03-04:00:00  13.4  13  95
 2005-10-22:15:00  11.3  13  95
 2005-10-25:15:00  10.3   2   2

I want to create another dataframe made up
of the values of dataframe1 which are not common
with dataframe2, ie. newD = D1 - (D1 intersection D2)

that is,
newD: 
   datesws   wc  pwc
 2005-10-19:12:00  10.8  80  81
 2005-10-20:12:00  12.3   5  15
 2005-10-21:15:00  12.3   3  15
 2005-10-23:12:00  12.3  13   2
 2005-10-24:15:00  10.3   2  95
 
Thanks for any help you can provide,

Augusto


Augusto Sanabria. MSc, PhD.
Mathematical Modeller
Risk Research Group
Geospatial  Earth Monitoring Division
Geoscience Australia (www.ga.gov.au)
Cnr. Jerrabomberra Av.  Hindmarsh Dr.
Symonston ACT 2601
Ph. (02) 6249-9155

__
R-help@stat.math.ethz.ch mailing list
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.


Re: [R] Extracting a subset from a dataframe

2007-02-22 Thread Xiaohui
Try: D1[setdiff(D1$dates,D2$dates) , ]

Xiaohui

[EMAIL PROTECTED] wrote:
 Good day everyone,

 Can anyone suggest an effective method to solve
 the following problem:

 I have 2 dataframes D1 and D2 as follows:

 D1:
 dates   ws   wc pwc
  2005-10-19:12:00  10.8  80  81
  2005-10-20:12:00  12.3   5  15
  2005-10-21:15:00  12.3   3  15
  2005-10-22:15:00  11.3  13  95
  2005-10-23:12:00  12.3  13   2
  2005-10-24:15:00  10.3   2  95
  2005-10-25:15:00  10.3   2   2

 D2:
 dates   ws   wc  pwc
  2005-02-02:15:00  17.5   5  96
  2005-02-19:15:00  20.1  15  97
  2005-02-20:18:00  16.5  95  95
  2005-03-03:18:00  10.3  95  95
  2005-03-04:00:00  13.4  13  95
  2005-10-22:15:00  11.3  13  95
  2005-10-25:15:00  10.3   2   2

 I want to create another dataframe made up
 of the values of dataframe1 which are not common
 with dataframe2, ie. newD = D1 - (D1 intersection D2)

 that is,
 newD: 
datesws   wc  pwc
  2005-10-19:12:00  10.8  80  81
  2005-10-20:12:00  12.3   5  15
  2005-10-21:15:00  12.3   3  15
  2005-10-23:12:00  12.3  13   2
  2005-10-24:15:00  10.3   2  95
  
 Thanks for any help you can provide,

 Augusto

 
 Augusto Sanabria. MSc, PhD.
 Mathematical Modeller
 Risk Research Group
 Geospatial  Earth Monitoring Division
 Geoscience Australia (www.ga.gov.au)
 Cnr. Jerrabomberra Av.  Hindmarsh Dr.
 Symonston ACT 2601
 Ph. (02) 6249-9155

 __
 R-help@stat.math.ethz.ch mailing list
 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.



__
R-help@stat.math.ethz.ch mailing list
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.


Re: [R] Extracting a subset from a dataframe

2007-02-22 Thread Frede Aakmann Tøgersen
Augusto

cnd - D1$dates %in% D2$dates
D1[!cnd,]

should do it.
 
Med venlig hilsen / Regards

Frede Aakmann Tøgersen
Forsker / Scientist



 AARHUS UNIVERSITET / UNIVERSITY OF AARHUS  
Det Jordbrugsvidenskabelige Fakultet / Faculty of Agricultural Sciences 
Forskningscenter Foulum / Research Centre Foulum
Genetik og Bioteknologi / Dept. of Genetics and Biotechnology   
Blichers Allé 20, P.O. BOX 50   
DK-8830 Tjele   

Tel: +45 8999 1900  
Direct:  +45 8999 1878  
Mobile:  +45
E-mail:  [EMAIL PROTECTED] mailto:[EMAIL PROTECTED]   
Web: www.agrsci.dk 
https://djfpost.agrsci.dk/exchweb/bin/redir.asp?URL=http://www.agrsci.dk/ 
 


Tilmeld dig DJF's nyhedsbrev / Subscribe Faculty of Agricultural Sciences 
Newsletter 
https://djfpost.agrsci.dk/exchweb/bin/redir.asp?URL=http://www.agrsci.dk/user/register?lan=dan-DK
 . 

Denne email kan indeholde fortrolig information. Enhver brug eller 
offentliggørelse af denne email uden skriftlig tilladelse fra DJF er ikke 
tilladt. Hvis De ikke er den tiltænkte adressat, bedes De venligst straks 
underrette DJF samt slette emailen.

This email may contain information that is confidential. Any use or publication 
of this email without written permission from Faculty of Agricultural Sciences 
is not allowed. If you are not the intended recipient, please notify Faculty of 
Agricultural Sciences immediately and delete this email.

 



Fra: [EMAIL PROTECTED] på vegne af [EMAIL PROTECTED]
Sendt: fr 23-02-2007 07:26
Til: R-help@stat.math.ethz.ch
Emne: [R] Extracting a subset from a dataframe



Good day everyone,

Can anyone suggest an effective method to solve
the following problem:

I have 2 dataframes D1 and D2 as follows:

D1:
dates   ws   wc pwc
 2005-10-19:12:00  10.8  80  81
 2005-10-20:12:00  12.3   5  15
 2005-10-21:15:00  12.3   3  15
 2005-10-22:15:00  11.3  13  95
 2005-10-23:12:00  12.3  13   2
 2005-10-24:15:00  10.3   2  95
 2005-10-25:15:00  10.3   2   2

D2:
dates   ws   wc  pwc
 2005-02-02:15:00  17.5   5  96
 2005-02-19:15:00  20.1  15  97
 2005-02-20:18:00  16.5  95  95
 2005-03-03:18:00  10.3  95  95
 2005-03-04:00:00  13.4  13  95
 2005-10-22:15:00  11.3  13  95
 2005-10-25:15:00  10.3   2   2

I want to create another dataframe made up
of the values of dataframe1 which are not common
with dataframe2, ie. newD = D1 - (D1 intersection D2)

that is,
newD:
   datesws   wc  pwc
 2005-10-19:12:00  10.8  80  81
 2005-10-20:12:00  12.3   5  15
 2005-10-21:15:00  12.3   3  15
 2005-10-23:12:00  12.3  13   2
 2005-10-24:15:00  10.3   2  95

Thanks for any help you can provide,

Augusto


Augusto Sanabria. MSc, PhD.
Mathematical Modeller
Risk Research Group
Geospatial  Earth Monitoring Division
Geoscience Australia (www.ga.gov.au)
Cnr. Jerrabomberra Av.  Hindmarsh Dr.
Symonston ACT 2601
Ph. (02) 6249-9155

__
R-help@stat.math.ethz.ch mailing list
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.

__
R-help@stat.math.ethz.ch mailing list
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.