function(yy=NEEmonthly) { period1 <-c(5922:5980) period2 <-c(6506:6787) period3 <-c(7860:7891) period4 <-c(8543:8608) period5 <-c(12121:12210) period6 <-c(13442:13561) period7 <-c(19422:19558) period8 <-c(19745:19853) period9 <-c(25436:25610) period10 <-c(25676:25755) period11 <-c(27169:27236) period12 <-c(27602:27666) period13 <-c(28591:28633) period14 <-c(28959:29058) period15 <-c(29555:29593) period16 <-c(31318:31364) period17 <-c(33676:33717) period18 <-c(39486:39762) period19 <-c(42648:42747) period20 <-c(42752:42831) period21 <-c(42931:43031) period22 <-c(43089:43370) period23 <-c(43373:43472) period24 <-c(44671:44755) period25 <-c(46635:46721) period26 <-c(52561:53647) period27 <-c(54405:54838) period28 <-c(57550:57823) period29 <-c(57979:58198) period30 <-c(58320:58541) period31 <-c(59330:59498) period32 <-c(60310:60501) period33 <-c(61755:61889) period34 <-c(63056:63191) period35 <-c(63245:63378) period36 <-c(63636:63759) period37 <-c(63767:63906) period38 <-c(64719:64865) period39 <-c(66594:66694) period40 <-c(74672:74762) period41 <-c(75802:75887) period42 <-c(75888:76015) period43 <-c(76788:76891) period44 <-c(80197:80303) period45 <-c(89872:90070) period46 <-c(93631:93763) period47 <-c(94344,94439) period48 <-c(94465:94822) period49 <-c(95670:95830) period50 <-c(97658:97752) xtime <-B.fill$xtime Year <- B.fill$Year Month <- B.fill$Month MNEE <- B.fill$NEE periodtime <- c(2001, 2001, 2001, 2001, 2001, 2001, 2001, 2001, 2001, 2001, 2001, 2001, 2002, 2002, 2002, 2002, 2002, 2003, 2003, 2003, 2003, 2003, 2003, 2003, 2003, 2004, 2004, 2004, 2004, 2004, 2004, 2004, 2004, 2004, 2004, 2004, 2004, 2004, 2004, 2005, 2005, 2005, 2005, 2005, 2006, 2006, 2006, 2006, 2006, 2006) for (j in 1:50){ if (periodtime[j]== 2001){ grab.p <- get(paste("period",j,sep="")) for (jj in 1: length(grab.p)){ MNEE[MNEE == MNEE[grab.p[jj]]]<- mean(MNEE[grab.p[jj]+17521],MNEE[grab.p[jj]+(2*17521)],MNEE[grab.p[jj]+(3*17521)],MNEE[grab.p[jj]+(4*17521)],MNEE[grab.p[jj]+(5*17521)], na.rm =FALSE) } } print(MNEE) if (periodtime[j]== 2002){ grab.p <- get(paste("period",j,sep="")) for (jj in 1: length(grab.p)){ MNEE[MNEE == MNEE[grab.p[jj]]] <- mean(MNEE[grab.p[jj]-17521],MNEE[grab.p[jj]+17521],MNEE[grab.p[jj]+(2*17521)],MNEE[grab.p[jj]+(3*17521)],MNEE[grab.p[jj]+(4*17521)], na.rm =FALSE) } } print(MNEE) if (periodtime[j]== 2003){ grab.p <- get(paste("period",j,sep="")) for (jj in 1: length(grab.p)){ MNEE[MNEE == MNEE[grab.p[jj]]] <- mean(MNEE[grab.p[jj]-(2*17521)],MNEE[grab.p[jj]-17521],MNEE[grab.p[jj]+(1*17521)],MNEE[grab.p[jj]+(2*17521)],MNEE[grab.p[jj]+(3*17521)], na.rm =FALSE) } } print(MNEE) if (periodtime[j]== 2004){ grab.p <- get(paste("period",j,sep="")) for (jj in 1: length(grab.p)){ MNEE[MNEE == MNEE[grab.p[jj]]] <- mean(MNEE[grab.p[jj]-(3*17521)],MNEE[grab.p[jj]-(2*17521)],MNEE[grab.p[jj]-(1*17521)],MNEE[grab.p[jj]+(1*17521)],MNEE[grab.p[jj]+(2*17521)], na.rm =FALSE) } } print(MNEE) if (periodtime[j]== 2005){ grab.p <- get(paste("period",j,sep="")) for (jj in 1: length(grab.p)){ MNEE[MNEE == MNEE[grab.p[jj]]] <- mean(MNEE[grab.p[jj]-(4*17521)],MNEE[grab.p[jj]-(3*17521)],MNEE[grab.p[jj]-(2*17521)],MNEE[grab.p[jj]-(1*17521)],MNEE[grab.p[jj]+(1*17521)], na.rm =FALSE) } } print(MNEE) if (periodtime[j]== 2006){ grab.p <- get(paste("period",j,sep="")) for (jj in 1: length(grab.p)){ MNEE[MNEE == MNEE[grab.p[jj]]] <- mean(MNEE[grab.p[jj]-(5*17521)],MNEE[grab.p[jj]-(4*17521)],MNEE[grab.p[jj]-(3*17521)],MNEE[grab.p[jj]-(2*17521)],MNEE[grab.p[jj]-(1*17521)], na.rm =FALSE) } } print(MNEE) } data.frame(xtime, Year, Month, MNEE) }