1

I have a timeseries data and I want to run the code for 1 year and break before iterating the process for next year. Can anyone help me with this? So far my code looks like this.

LR= 0.004    #Mean lapse rate 
L_Tmean = array(dim=c(length(Met_data), length(elevation_bands)))
for (i in 1:length(elevation_bands)){
  if (length(Met_data) > 366){ break}
  else{ L_Tmean[,i] = Met_data$Temp- LR*(elevation_bands[i]-Jasper_elevation)
  print(i)

  }

}

This is not providing me what I want. Thank you for your help.

Gunjan
  • 11
  • 1
  • Please provide `elevation_bands`! – jay.sf Sep 18 '19 at 18:20
  • [`R.utils::withTimeout`](https://github.com/HenrikBengtsson/R.utils/blob/develop/R/withTimeout.R) exists. @landau provided a much-reduced version in https://stackoverflow.com/a/53018594 that works in base R (no other packages) and is much easier to read, imo. – r2evans Sep 18 '19 at 18:20
  • 1
    Why not split the data by year, use apply-family functions and then combine? – Fnguyen Sep 18 '19 at 18:23

0 Answers0