Quantcast
Channel: Active questions tagged r - Stack Overflow
Viewing all articles
Browse latest Browse all 201839

Combine data frame with one value for each date with data frame with several entries per date

$
0
0

I want to merge two dataframes. DF2 has one temperature value for each day while DF1 has several entries for each day. So I want to look up the temperature for one day in DF2 and have it added to every entry of this day in dataframe 1.

I guess a loop would work best but being quite new to R I can't figure out how it has to look like

DF1$Date<-c(1.8.18, 1.8.18, 2.8.18)
DF2$Date<-c(1.8.18, 2.8.18, 3.8.18)
DF2$Temperature<-c(17,18,17)
DF2$Difference<-c(0.5,0.4,0.5)

This is the expected output:

DF1$Date<-c(1.8.18, 1.8.18, 2.8.18)
DF1$Temperature<-c(17,17,18)
DF1$Difference<-c(0.5,0.5,0.4)

Viewing all articles
Browse latest Browse all 201839

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>