Skip to content
Prev 165627 / 398513 Next

Conditional operation on multiple columns from two data frames

The suggestion below was made.

df1$Date <- as.Date(df1$Date)
df2$Date <- as.Date(df2$Date)
 
ifelse(df1$ID==df2$ID & df1$Date-df2$Date<0.5,df1$y-df2$y, NA)

However, because my dataframe rows do not align, I need the conditionals to
be tested on every combination of cells.  I'm starting to think I need to
use tapply?  

Tim