Merge will give you an output like below and you should be able to
find the value you need:
> merge(df1, df2, by='ID', all=TRUE)
ID Date.x y.x x.x Date.y
y.y x.y
1 1NANA 2007-05-31 23:00:00
-20.82907 217.7022
2 1
tsippel wrote:
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 s
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
Sorry...I was unaware I needed to 'deput' to deparse data examples into a
useful format. The data examples I provided initially are deparsed below:
df1<-
list(ID = c(2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3), Date = c("2007-05-30
18:48:20",
"2007-05-30 20:21:56", "2007-06-02 09:39:58", "2007-06-02 1
Hi-
I have two data frames for which I wish to conditionally subtract the values
of one dataframe from the other.
I want to subtract df1$x from df2$x when their id is equal and the absolute
value of difference between the dates is 12 hours or less. If there is no
match of equal id's and dates le
5 matches
Mail list logo