I am trying to combine two data sets, one with daily values and one with weekly values.  SurveyData conatins environmental data collected on a daily basis.  sat.data contains satellite sea surface temperature that is an average of satellite measurements over a six day period.  I would like to combine the two files so that my output file has the daily dates from SurveyData and the weekly average from sat.data that corresponds to that day.  I have written a loop that does exactly what I want, but it takes a very long time.  Is there a faster way to do this?  What I have so far is below.
Thanks,
Tim

#Compare dates
 for(i in 1:length(SurveyData$Date))
 {
 print(i)
 for(j in 1:length(sat.data$Date.Start))
  {
  if(
  sat.data$Date.Start[j]<=SurveyData$Date[i] &
  sat.data$Date.End[j]>=SurveyData$Date[i])
  survey.data[i]<- sat.data$data[j]
  }
 } 
 
#Create data frame with final data
 final.data<-data.frame(SurveyData$Record,SurveyData$Date,survey.data)
 
#Write data to file
 write.csv(final.data,file="Combined.csv")



      
	[[alternative HTML version deleted]]

