Re: [R] Conditional merging in R & if then statement

2012-08-31 Thread Jeff Newmiller
1) just because you don't use sqldf doesn't make it better. merge only does the join, not the conditions, so you have to apply them after merge. Untested (you should provide a complete example): result <- merge ( detail, pdetail, by=TDATE, suffixes=c(".a",".b") ) result <- subset ( result, STIM.

Re: [R] Conditional merging in R & if then statement

2012-08-31 Thread David Winsemius
On Aug 31, 2012, at 10:11 AM, ramoss wrote: > 1)I am wandering how the following SQL statement can be written in R language > w/o using sqldf: > create table detail2 as > select a.* > from detail a, > pdetail b > where a.TDATE=b.TDATE > and(a.STIM >= b.STIM and a.STIM <=b.MAXTIM) >

[R] Conditional merging in R & if then statement

2012-08-31 Thread ramoss
1)I am wandering how the following SQL statement can be written in R language w/o using sqldf: create table detail2 as select a.* from detail a, pdetail b where a.TDATE=b.TDATE and(a.STIM >= b.STIM and a.STIM <=b.MAXTIM) 2) when try if then in R it only applies to the 1st row & not t