From mboxrd@z Thu Jan 1 00:00:00 1970 From: Vikas Rawal Subject: Re: Trouble evaluating R source code blocks with C-c C-c Date: Sun, 29 May 2016 18:43:58 +0530 Message-ID: <5F862231-C04A-4BF6-8A2A-2377AF000374@agrarianresearch.org> References: <2BE21056-50D3-49CE-8B0D-5467D182B7B5@agrarianresearch.org> <2E8B017B-F4AB-454D-81A1-E61F55F4F958@agrarianresearch.org> Mime-Version: 1.0 (Mac OS X Mail 8.2 \(2104\)) Content-Type: multipart/alternative; boundary="Apple-Mail=_CD401725-A451-45DD-898A-584282E2D51C" Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:48764) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b70Xe-00088g-UV for emacs-orgmode@gnu.org; Sun, 29 May 2016 09:14:10 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1b70Xa-0002nx-6d for emacs-orgmode@gnu.org; Sun, 29 May 2016 09:14:06 -0400 Received: from mail-pf0-x22c.google.com ([2607:f8b0:400e:c00::22c]:36338) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b70XZ-0002ni-MB for emacs-orgmode@gnu.org; Sun, 29 May 2016 09:14:02 -0400 Received: by mail-pf0-x22c.google.com with SMTP id f144so43189701pfa.3 for ; Sun, 29 May 2016 06:14:01 -0700 (PDT) In-Reply-To: List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: "Emacs-orgmode" To: "Charles C. Berry" Cc: William Denton , org-mode mailing list --Apple-Mail=_CD401725-A451-45DD-898A-584282E2D51C Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=us-ascii And this time it has this additional line: = run-hook-with-args-until-success(org-babel-execute-safely-maybe) ------------------ sit-for(0.25) org-babel-comint-eval-invisibly-and-wait-for-file("type2" = "/var/folders/hj/hqfjch716qg5php160jbtfgh0000gn/T/babel-53134TSq/R-53134vJ= F" "{\n function(object,transfer.file) {\n object\n = invisible(\n if (\n inherits(\n = try(\n {\n = tfile<-tempfile()\n write.table(object, = file=3Dtfile, sep=3D\"\\t\",\n = na=3D\"nil\",row.names=3DFALSE,col.names=3DTRUE,\n = quote=3DFALSE)\n = file.rename(tfile,transfer.file)\n },\n = silent=3DTRUE),\n \"try-error\"))\n = {\n if(!file.exists(transfer.file))\n = file.create(transfer.file)\n }\n = )\n = }\n}(object=3D.Last.value,transfer.file=3D\"/var/folders/hj/hqfjch716qg5ph= p160jbtfgh0000gn/T/babel-53134TSq/R-53134vJF\")") org-babel-R-evaluate-session("type2" = "library(plyr)\nlibrary(Hmisc)\ng->tempg\n\n = # = CV_untreated\nas.integer(tempg$state_region/10)->tempg$State.code.68\nfact= or(tempg$State.code.68)->tempg$State.code.68\ndata.frame(State=3D0,adjuste= d_cv=3D0)->e\n\nfor (i in c(1:35)) {\n = subset(tempg,as.numeric(tempg$State.code.68)=3D=3Di)->dd\n = wtd.var(dd$adj_cal,weight=3Ddd$weight)^0.5/wtd.mean(dd$adj_cal,weight=3Ddd= $weight)->cvs\n data.frame(State=3Di,adjusted_cv=3Dcvs)->e1\n = rbind(e,e1)->e\n}\n\nddply(tempg,.(State.code.68),summarise,value=3Dwtd.me= an(adj_cal,weight))->s1\n\ndata.frame(State=3D99,adjusted_cv=3D0)->f2\nwtd= .var(tempg$adj_cal,weight=3Dtempg$weight)^0.5/wtd.mean(tempg$adj_cal,weigh= t=3Dtempg$weight)->f2[1,2]\nrbind(e,f2)->cv1\n\n = # CV_grouped = data\nddply(tempg,.(sex,agegroup,fractile_adj),summarise,calories=3Dwtd.me= an(adj_cal,weight))->l1\nddply(tempg,.(sex,agegroup,fractile_adj),summaris= e,weight=3Dsum(weight))->w\n\nmerge(w,l1,by=3Dc(\"sex\",\"agegroup\",\"fra= ctile_adj\"))->l1\n\nddply(tempg,.(fractile_adj_state,State.code.68,agegro= up,sex),summarise,value=3Dwtd.mean(adj_cal,weight))->s3\n\nddply(tempg,.(f= ractile_adj_state,State.code.68,agegroup,sex),summarise,sum_weight=3Dsum(w= eight))->sw\n\nmerge(s3,sw,by=3Dc(\"fractile_adj_state\",\"State.code.68\"= ,\"agegroup\",\"sex\"))->s3\n\nfactor(s3$State.code.68)->s3$State.code.68\= n\ndata.frame(State=3D99,grouped_cv=3Dwtd.var(l1$calories,weight=3Dl1$weig= ht)^0.5/wtd.mean(l1$calories,weight=3Dl1$weight))->cv3\n\nfor (i in = c(1:35)) {\n subset(s3,as.numeric(s3$State.code.68)=3D=3Di)->s3sub\n = = data.frame(State=3Di,grouped_cv=3Dwtd.var(s3sub$value,s3sub$sum_weight)^0.= 5/wtd.mean(s3sub$value,s3sub$sum_weight))->t1\n = rbind(cv3,t1)->cv3\n}\n\n# CV_from regression = model\nregdata->p\nexp(predict.lm(reg))->p$predicted_cal\n\ndata.frame(Sta= te=3D99,predicted_cv=3Dwtd.var(p$predicted_cal,weight=3Dp$weight)^0.5/wtd.= mean(p$predicted_cal,weight=3Dp$weight),adjr2=3Dsummary(reg)$adj.r.squared= )->cv2\n\n\n#data.frame(State=3D0,predicted_cv=3D0,adjr2=3D0)->e\n\nfor = (i in c(1:35)) {\n = subset(regdata,as.numeric(p$State.code.68)=3D=3Di)->dd\n = factor(dd$state_region)->dd$state_region\nfmla <- as.formula(\n = ifelse(length(levels(dd$state_region))=3D=3D1,\"log_cal~sector+sex+AgeChil= d+AgeAdult+foodprice+log(MPCE)\",\"log_cal~sector+sex+AgeChild+AgeAdult+fo= odprice+log(MPCE)+state_region\"))\n\n\n = lm(fmla,data=3Ddd,weights=3Dweight)->regstate\n = exp(predict.lm(regstate))->dd$predicted_cal\n = wtd.var(dd$predicted_cal,weight=3Ddd$weight)^0.5/wtd.mean(dd$predicted_cal= ,weight=3Ddd$weight)->cvs\n = data.frame(State=3Di,predicted_cv=3Dcvs,adjr2=3Dsummary(regstate)$adj.r.sq= uared)->e1\n = rbind(cv2,e1)->cv2\n}\n\nsubset(cv2,select=3D-adjr2)->cv2\n\nmerge(cv1,cv3= ,by=3D\"State\")->t\nmerge(t,cv2,by=3D\"State\")->t\nmerge(t,statecode,by.= x=3D\"State\",by.y=3D\"State.code.68\",all.x=3DTRUE)->t\nt$State.68[t$Stat= e=3D=3D99]<-\"India\"\nround(t$grouped_cv,4)->t$grouped_cv\nround(t$adjust= ed_cv,4)->t$adjusted_cv\nround(t$predicted_cv,4)->t$predicted_cv\nnames(t)= <-c(\"State.code.68\",\"CV (unit-level data)\",\"CV (grouped = data)\",\"CV (based on regression = model)\",\"State\")\nt->finvar\nt[order(t$State),c(5,2,3,4)]" value = ("replace" "value") t nil) org-babel-R-evaluate("type2" = "library(plyr)\nlibrary(Hmisc)\ng->tempg\n\n = # = CV_untreated\nas.integer(tempg$state_region/10)->tempg$State.code.68\nfact= or(tempg$State.code.68)->tempg$State.code.68\ndata.frame(State=3D0,adjuste= d_cv=3D0)->e\n\nfor (i in c(1:35)) {\n = subset(tempg,as.numeric(tempg$State.code.68)=3D=3Di)->dd\n = wtd.var(dd$adj_cal,weight=3Ddd$weight)^0.5/wtd.mean(dd$adj_cal,weight=3Ddd= $weight)->cvs\n data.frame(State=3Di,adjusted_cv=3Dcvs)->e1\n = rbind(e,e1)->e\n}\n\nddply(tempg,.(State.code.68),summarise,value=3Dwtd.me= an(adj_cal,weight))->s1\n\ndata.frame(State=3D99,adjusted_cv=3D0)->f2\nwtd= .var(tempg$adj_cal,weight=3Dtempg$weight)^0.5/wtd.mean(tempg$adj_cal,weigh= t=3Dtempg$weight)->f2[1,2]\nrbind(e,f2)->cv1\n\n = # CV_grouped = data\nddply(tempg,.(sex,agegroup,fractile_adj),summarise,calories=3Dwtd.me= an(adj_cal,weight))->l1\nddply(tempg,.(sex,agegroup,fractile_adj),summaris= e,weight=3Dsum(weight))->w\n\nmerge(w,l1,by=3Dc(\"sex\",\"agegroup\",\"fra= ctile_adj\"))->l1\n\nddply(tempg,.(fractile_adj_state,State.code.68,agegro= up,sex),summarise,value=3Dwtd.mean(adj_cal,weight))->s3\n\nddply(tempg,.(f= ractile_adj_state,State.code.68,agegroup,sex),summarise,sum_weight=3Dsum(w= eight))->sw\n\nmerge(s3,sw,by=3Dc(\"fractile_adj_state\",\"State.code.68\"= ,\"agegroup\",\"sex\"))->s3\n\nfactor(s3$State.code.68)->s3$State.code.68\= n\ndata.frame(State=3D99,grouped_cv=3Dwtd.var(l1$calories,weight=3Dl1$weig= ht)^0.5/wtd.mean(l1$calories,weight=3Dl1$weight))->cv3\n\nfor (i in = c(1:35)) {\n subset(s3,as.numeric(s3$State.code.68)=3D=3Di)->s3sub\n = = data.frame(State=3Di,grouped_cv=3Dwtd.var(s3sub$value,s3sub$sum_weight)^0.= 5/wtd.mean(s3sub$value,s3sub$sum_weight))->t1\n = rbind(cv3,t1)->cv3\n}\n\n# CV_from regression = model\nregdata->p\nexp(predict.lm(reg))->p$predicted_cal\n\ndata.frame(Sta= te=3D99,predicted_cv=3Dwtd.var(p$predicted_cal,weight=3Dp$weight)^0.5/wtd.= mean(p$predicted_cal,weight=3Dp$weight),adjr2=3Dsummary(reg)$adj.r.squared= )->cv2\n\n\n#data.frame(State=3D0,predicted_cv=3D0,adjr2=3D0)->e\n\nfor = (i in c(1:35)) {\n = subset(regdata,as.numeric(p$State.code.68)=3D=3Di)->dd\n = factor(dd$state_region)->dd$state_region\nfmla <- as.formula(\n = ifelse(length(levels(dd$state_region))=3D=3D1,\"log_cal~sector+sex+AgeChil= d+AgeAdult+foodprice+log(MPCE)\",\"log_cal~sector+sex+AgeChild+AgeAdult+fo= odprice+log(MPCE)+state_region\"))\n\n\n = lm(fmla,data=3Ddd,weights=3Dweight)->regstate\n = exp(predict.lm(regstate))->dd$predicted_cal\n = wtd.var(dd$predicted_cal,weight=3Ddd$weight)^0.5/wtd.mean(dd$predicted_cal= ,weight=3Ddd$weight)->cvs\n = data.frame(State=3Di,predicted_cv=3Dcvs,adjr2=3Dsummary(regstate)$adj.r.sq= uared)->e1\n = rbind(cv2,e1)->cv2\n}\n\nsubset(cv2,select=3D-adjr2)->cv2\n\nmerge(cv1,cv3= ,by=3D\"State\")->t\nmerge(t,cv2,by=3D\"State\")->t\nmerge(t,statecode,by.= x=3D\"State\",by.y=3D\"State.code.68\",all.x=3DTRUE)->t\nt$State.68[t$Stat= e=3D=3D99]<-\"India\"\nround(t$grouped_cv,4)->t$grouped_cv\nround(t$adjust= ed_cv,4)->t$adjusted_cv\nround(t$predicted_cv,4)->t$predicted_cv\nnames(t)= <-c(\"State.code.68\",\"CV (unit-level data)\",\"CV (grouped = data)\",\"CV (based on regression = model)\",\"State\")\nt->finvar\nt[order(t$State),c(5,2,3,4)]" value = ("replace" "value") t nil) org-babel-execute:R("library(plyr)\nlibrary(Hmisc)\ng->tempg\n\n = # = CV_untreated\nas.integer(tempg$state_region/10)->tempg$State.code.68\nfact= or(tempg$State.code.68)->tempg$State.code.68\ndata.frame(State=3D0,adjuste= d_cv=3D0)->e\n\nfor (i in c(1:35)) {\n = subset(tempg,as.numeric(tempg$State.code.68)=3D=3Di)->dd\n = wtd.var(dd$adj_cal,weight=3Ddd$weight)^0.5/wtd.mean(dd$adj_cal,weight=3Ddd= $weight)->cvs\n data.frame(State=3Di,adjusted_cv=3Dcvs)->e1\n = rbind(e,e1)->e\n}\n\nddply(tempg,.(State.code.68),summarise,value=3Dwtd.me= an(adj_cal,weight))->s1\n\ndata.frame(State=3D99,adjusted_cv=3D0)->f2\nwtd= .var(tempg$adj_cal,weight=3Dtempg$weight)^0.5/wtd.mean(tempg$adj_cal,weigh= t=3Dtempg$weight)->f2[1,2]\nrbind(e,f2)->cv1\n\n = # CV_grouped = data\nddply(tempg,.(sex,agegroup,fractile_adj),summarise,calories=3Dwtd.me= an(adj_cal,weight))->l1\nddply(tempg,.(sex,agegroup,fractile_adj),summaris= e,weight=3Dsum(weight))->w\n\nmerge(w,l1,by=3Dc(\"sex\",\"agegroup\",\"fra= ctile_adj\"))->l1\n\nddply(tempg,.(fractile_adj_state,State.code.68,agegro= up,sex),summarise,value=3Dwtd.mean(adj_cal,weight))->s3\n\nddply(tempg,.(f= ractile_adj_state,State.code.68,agegroup,sex),summarise,sum_weight=3Dsum(w= eight))->sw\n\nmerge(s3,sw,by=3Dc(\"fractile_adj_state\",\"State.code.68\"= ,\"agegroup\",\"sex\"))->s3\n\nfactor(s3$State.code.68)->s3$State.code.68\= n\ndata.frame(State=3D99,grouped_cv=3Dwtd.var(l1$calories,weight=3Dl1$weig= ht)^0.5/wtd.mean(l1$calories,weight=3Dl1$weight))->cv3\n\nfor (i in = c(1:35)) {\n subset(s3,as.numeric(s3$State.code.68)=3D=3Di)->s3sub\n = = data.frame(State=3Di,grouped_cv=3Dwtd.var(s3sub$value,s3sub$sum_weight)^0.= 5/wtd.mean(s3sub$value,s3sub$sum_weight))->t1\n = rbind(cv3,t1)->cv3\n}\n\n# CV_from regression = model\nregdata->p\nexp(predict.lm(reg))->p$predicted_cal\n\ndata.frame(Sta= te=3D99,predicted_cv=3Dwtd.var(p$predicted_cal,weight=3Dp$weight)^0.5/wtd.= mean(p$predicted_cal,weight=3Dp$weight),adjr2=3Dsummary(reg)$adj.r.squared= )->cv2\n\n\n#data.frame(State=3D0,predicted_cv=3D0,adjr2=3D0)->e\n\nfor = (i in c(1:35)) {\n = subset(regdata,as.numeric(p$State.code.68)=3D=3Di)->dd\n = factor(dd$state_region)->dd$state_region\nfmla <- as.formula(\n = ifelse(length(levels(dd$state_region))=3D=3D1,\"log_cal~sector+sex+AgeChil= d+AgeAdult+foodprice+log(MPCE)\",\"log_cal~sector+sex+AgeChild+AgeAdult+fo= odprice+log(MPCE)+state_region\"))\n\n\n = lm(fmla,data=3Ddd,weights=3Dweight)->regstate\n = exp(predict.lm(regstate))->dd$predicted_cal\n = wtd.var(dd$predicted_cal,weight=3Ddd$weight)^0.5/wtd.mean(dd$predicted_cal= ,weight=3Ddd$weight)->cvs\n = data.frame(State=3Di,predicted_cv=3Dcvs,adjr2=3Dsummary(regstate)$adj.r.sq= uared)->e1\n = rbind(cv2,e1)->cv2\n}\n\nsubset(cv2,select=3D-adjr2)->cv2\n\nmerge(cv1,cv3= ,by=3D\"State\")->t\nmerge(t,cv2,by=3D\"State\")->t\nmerge(t,statecode,by.= x=3D\"State\",by.y=3D\"State.code.68\",all.x=3DTRUE)->t\nt$State.68[t$Stat= e=3D=3D99]<-\"India\"\nround(t$grouped_cv,4)->t$grouped_cv\nround(t$adjust= ed_cv,4)->t$adjusted_cv\nround(t$predicted_cv,4)->t$predicted_cv\nnames(t)= <-c(\"State.code.68\",\"CV (unit-level data)\",\"CV (grouped = data)\",\"CV (based on regression = model)\",\"State\")\nt->finvar\nt[order(t$State),c(5,2,3,4)]" = ((:colname-names) (:rowname-names) (:result-params "replace" "value") = (:result-type . value) (:comments . "") (:shebang . "") (:cache . "no") = (:padline . "") (:noweb . "no") (:tangle . "no") (:exports . "results") = (:results . "replace value") (:hlines . "no") (:session . "type2") = (:colnames . "yes") (:hline . "yes"))) org-babel-execute-src-block(nil) org-babel-execute-src-block-maybe() org-babel-execute-maybe() org-babel-execute-safely-maybe() run-hook-with-args-until-success(org-babel-execute-safely-maybe) org-ctrl-c-ctrl-c(nil) call-interactively(org-ctrl-c-ctrl-c nil nil) command-execute(org-ctrl-c-ctrl-c) > On 28-May-2016, at 10:31 pm, Charles C. Berry = wrote: >=20 >=20 > p.s. one more thing - below >=20 > On Sat, 28 May 2016, Charles C. Berry wrote: >=20 >> On Sat, 28 May 2016, William Denton wrote: >>=20 >>> On 28 May 2016, Vikas Rawal wrote: >>>> Thanks John. Appreciate that you cared to respond to such a vague = query. I am at a loss with this one. It does not happen all the time. I = think it happens when I am processing large datasets, and CPUs and RAM = of my system are struggling to keep up. But I could be wrong. >>> I've had the same kind of thing happen---but C-g (sometimes many) to = kill the command, then rerunning, usually works without any trouble. = Some strange combination of CPU and RAM and all that, the kind of thing = that's not easily reproducible. >>=20 >> Try this: customize `debug-on-quit' to `t' (and set for current = session). >>=20 >> Then when you have to quit via C-g, you will get a backtrace showing = where the process was hanging and how it got there. This might be = helpful in figuring out what is going on. >>=20 >> Run your code and when you finally have to C-g out copy the = *Backtrace* buffer and report it back here (or on the ESS list if = appropriate). >>=20 >=20 > After you copy the buffer, you should type 'q' in the *Backtrace* = buffer to finish up or you may have some odd messages and hangups = afterwards. >=20 > Chuck --Apple-Mail=_CD401725-A451-45DD-898A-584282E2D51C Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset=us-ascii And this time it has this additional line:   = run-hook-with-args-until-success(org-babel-execute-safely-maybe)

------------------

  sit-for(0.25)
  = org-babel-comint-eval-invisibly-and-wait-for-file("type2" = "/var/folders/hj/hqfjch716qg5php160jbtfgh0000gn/T/babel-53134TSq/R-53134vJ= F" "{\n    function(object,transfer.file) {\n     =    object\n        invisible(\n   =          if (\n         =        inherits(\n         =            try(\n       =                  {\n   =                     =      tfile<-tempfile()\n         =                   =  write.table(object, file=3Dtfile, sep=3D\"\\t\",\n               =                     =      na=3D\"nil\",row.names=3DFALSE,col.names=3DTRUE,\n =                     =                   =  quote=3DFALSE)\n               =             =  file.rename(tfile,transfer.file)\n         =                },\n   =                     =  silent=3DTRUE),\n               =      \"try-error\"))\n           =      {\n               =      if(!file.exists(transfer.file))\n     =                   =  file.create(transfer.file)\n           =      }\n            )\n =   =  }\n}(object=3D.Last.value,transfer.file=3D\"/var/folders/hj/hqfjch71= 6qg5php160jbtfgh0000gn/T/babel-53134TSq/R-53134vJF\")")
  org-babel-R-evaluate-session("type2" = "library(plyr)\nlibrary(Hmisc)\ng->tempg\n\n       =                     =              # = CV_untreated\nas.integer(tempg$state_region/10)->tempg$State.code.68\nf= actor(tempg$State.code.68)->tempg$State.code.68\ndata.frame(State=3D0,a= djusted_cv=3D0)->e\n\nfor (i in c(1:35)) {\n   =  subset(tempg,as.numeric(tempg$State.code.68)=3D=3Di)->dd\n =   =  wtd.var(dd$adj_cal,weight=3Ddd$weight)^0.5/wtd.mean(dd$adj_cal,weigh= t=3Ddd$weight)->cvs\n   =  data.frame(State=3Di,adjusted_cv=3Dcvs)->e1\n   =  rbind(e,e1)->e\n}\n\nddply(tempg,.(State.code.68),summarise,value= =3Dwtd.mean(adj_cal,weight))->s1\n\ndata.frame(State=3D99,adjusted_cv=3D= 0)->f2\nwtd.var(tempg$adj_cal,weight=3Dtempg$weight)^0.5/wtd.mean(tempg= $adj_cal,weight=3Dtempg$weight)->f2[1,2]\nrbind(e,f2)->cv1\n\n =                     =                    # = CV_grouped = data\nddply(tempg,.(sex,agegroup,fractile_adj),summarise,calories=3Dwtd.me= an(adj_cal,weight))->l1\nddply(tempg,.(sex,agegroup,fractile_adj),summa= rise,weight=3Dsum(weight))->w\n\nmerge(w,l1,by=3Dc(\"sex\",\"agegroup\"= ,\"fractile_adj\"))->l1\n\nddply(tempg,.(fractile_adj_state,State.code.= 68,agegroup,sex),summarise,value=3Dwtd.mean(adj_cal,weight))->s3\n\nddp= ly(tempg,.(fractile_adj_state,State.code.68,agegroup,sex),summarise,sum_we= ight=3Dsum(weight))->sw\n\nmerge(s3,sw,by=3Dc(\"fractile_adj_state\",\"= State.code.68\",\"agegroup\",\"sex\"))->s3\n\nfactor(s3$State.code.68)-= >s3$State.code.68\n\ndata.frame(State=3D99,grouped_cv=3Dwtd.var(l1$calo= ries,weight=3Dl1$weight)^0.5/wtd.mean(l1$calories,weight=3Dl1$weight))->= ;cv3\n\nfor (i in c(1:35)) {\n   =  subset(s3,as.numeric(s3$State.code.68)=3D=3Di)->s3sub\n   =  data.frame(State=3Di,grouped_cv=3Dwtd.var(s3sub$value,s3sub$sum_weig= ht)^0.5/wtd.mean(s3sub$value,s3sub$sum_weight))->t1\n   =  rbind(cv3,t1)->cv3\n}\n\n# CV_from regression = model\nregdata->p\nexp(predict.lm(reg))->p$predicted_cal\n\ndata.fra= me(State=3D99,predicted_cv=3Dwtd.var(p$predicted_cal,weight=3Dp$weight)^0.= 5/wtd.mean(p$predicted_cal,weight=3Dp$weight),adjr2=3Dsummary(reg)$adj.r.s= quared)->cv2\n\n\n#data.frame(State=3D0,predicted_cv=3D0,adjr2=3D0)->= ;e\n\nfor (i in c(1:35)) {\n   =  subset(regdata,as.numeric(p$State.code.68)=3D=3Di)->dd\n   =  factor(dd$state_region)->dd$state_region\nfmla <- = as.formula(\n         = ifelse(length(levels(dd$state_region))=3D=3D1,\"log_cal~sector+sex+AgeChil= d+AgeAdult+foodprice+log(MPCE)\",\"log_cal~sector+sex+AgeChild+AgeAdult+fo= odprice+log(MPCE)+state_region\"))\n\n\n   =  lm(fmla,data=3Ddd,weights=3Dweight)->regstate\n   =  exp(predict.lm(regstate))->dd$predicted_cal\n   =  wtd.var(dd$predicted_cal,weight=3Ddd$weight)^0.5/wtd.mean(dd$predict= ed_cal,weight=3Ddd$weight)->cvs\n   =  data.frame(State=3Di,predicted_cv=3Dcvs,adjr2=3Dsummary(regstate)$ad= j.r.squared)->e1\n   =  rbind(cv2,e1)->cv2\n}\n\nsubset(cv2,select=3D-adjr2)->cv2\n\nm= erge(cv1,cv3,by=3D\"State\")->t\nmerge(t,cv2,by=3D\"State\")->t\nmer= ge(t,statecode,by.x=3D\"State\",by.y=3D\"State.code.68\",all.x=3DTRUE)->= ;t\nt$State.68[t$State=3D=3D99]<-\"India\"\nround(t$grouped_cv,4)->t= $grouped_cv\nround(t$adjusted_cv,4)->t$adjusted_cv\nround(t$predicted_c= v,4)->t$predicted_cv\nnames(t)<-c(\"State.code.68\",\"CV = (unit-level data)\",\"CV (grouped data)\",\"CV (based on regression = model)\",\"State\")\nt->finvar\nt[order(t$State),c(5,2,3,4)]" value = ("replace" "value") t nil)
  = org-babel-R-evaluate("type2" = "library(plyr)\nlibrary(Hmisc)\ng->tempg\n\n       =                     =              # = CV_untreated\nas.integer(tempg$state_region/10)->tempg$State.code.68\nf= actor(tempg$State.code.68)->tempg$State.code.68\ndata.frame(State=3D0,a= djusted_cv=3D0)->e\n\nfor (i in c(1:35)) {\n   =  subset(tempg,as.numeric(tempg$State.code.68)=3D=3Di)->dd\n =   =  wtd.var(dd$adj_cal,weight=3Ddd$weight)^0.5/wtd.mean(dd$adj_cal,weigh= t=3Ddd$weight)->cvs\n   =  data.frame(State=3Di,adjusted_cv=3Dcvs)->e1\n   =  rbind(e,e1)->e\n}\n\nddply(tempg,.(State.code.68),summarise,value= =3Dwtd.mean(adj_cal,weight))->s1\n\ndata.frame(State=3D99,adjusted_cv=3D= 0)->f2\nwtd.var(tempg$adj_cal,weight=3Dtempg$weight)^0.5/wtd.mean(tempg= $adj_cal,weight=3Dtempg$weight)->f2[1,2]\nrbind(e,f2)->cv1\n\n =                     =                    # = CV_grouped = data\nddply(tempg,.(sex,agegroup,fractile_adj),summarise,calories=3Dwtd.me= an(adj_cal,weight))->l1\nddply(tempg,.(sex,agegroup,fractile_adj),summa= rise,weight=3Dsum(weight))->w\n\nmerge(w,l1,by=3Dc(\"sex\",\"agegroup\"= ,\"fractile_adj\"))->l1\n\nddply(tempg,.(fractile_adj_state,State.code.= 68,agegroup,sex),summarise,value=3Dwtd.mean(adj_cal,weight))->s3\n\nddp= ly(tempg,.(fractile_adj_state,State.code.68,agegroup,sex),summarise,sum_we= ight=3Dsum(weight))->sw\n\nmerge(s3,sw,by=3Dc(\"fractile_adj_state\",\"= State.code.68\",\"agegroup\",\"sex\"))->s3\n\nfactor(s3$State.code.68)-= >s3$State.code.68\n\ndata.frame(State=3D99,grouped_cv=3Dwtd.var(l1$calo= ries,weight=3Dl1$weight)^0.5/wtd.mean(l1$calories,weight=3Dl1$weight))->= ;cv3\n\nfor (i in c(1:35)) {\n   =  subset(s3,as.numeric(s3$State.code.68)=3D=3Di)->s3sub\n   =  data.frame(State=3Di,grouped_cv=3Dwtd.var(s3sub$value,s3sub$sum_weig= ht)^0.5/wtd.mean(s3sub$value,s3sub$sum_weight))->t1\n   =  rbind(cv3,t1)->cv3\n}\n\n# CV_from regression = model\nregdata->p\nexp(predict.lm(reg))->p$predicted_cal\n\ndata.fra= me(State=3D99,predicted_cv=3Dwtd.var(p$predicted_cal,weight=3Dp$weight)^0.= 5/wtd.mean(p$predicted_cal,weight=3Dp$weight),adjr2=3Dsummary(reg)$adj.r.s= quared)->cv2\n\n\n#data.frame(State=3D0,predicted_cv=3D0,adjr2=3D0)->= ;e\n\nfor (i in c(1:35)) {\n   =  subset(regdata,as.numeric(p$State.code.68)=3D=3Di)->dd\n   =  factor(dd$state_region)->dd$state_region\nfmla <- = as.formula(\n         = ifelse(length(levels(dd$state_region))=3D=3D1,\"log_cal~sector+sex+AgeChil= d+AgeAdult+foodprice+log(MPCE)\",\"log_cal~sector+sex+AgeChild+AgeAdult+fo= odprice+log(MPCE)+state_region\"))\n\n\n   =  lm(fmla,data=3Ddd,weights=3Dweight)->regstate\n   =  exp(predict.lm(regstate))->dd$predicted_cal\n   =  wtd.var(dd$predicted_cal,weight=3Ddd$weight)^0.5/wtd.mean(dd$predict= ed_cal,weight=3Ddd$weight)->cvs\n   =  data.frame(State=3Di,predicted_cv=3Dcvs,adjr2=3Dsummary(regstate)$ad= j.r.squared)->e1\n   =  rbind(cv2,e1)->cv2\n}\n\nsubset(cv2,select=3D-adjr2)->cv2\n\nm= erge(cv1,cv3,by=3D\"State\")->t\nmerge(t,cv2,by=3D\"State\")->t\nmer= ge(t,statecode,by.x=3D\"State\",by.y=3D\"State.code.68\",all.x=3DTRUE)->= ;t\nt$State.68[t$State=3D=3D99]<-\"India\"\nround(t$grouped_cv,4)->t= $grouped_cv\nround(t$adjusted_cv,4)->t$adjusted_cv\nround(t$predicted_c= v,4)->t$predicted_cv\nnames(t)<-c(\"State.code.68\",\"CV = (unit-level data)\",\"CV (grouped data)\",\"CV (based on regression = model)\",\"State\")\nt->finvar\nt[order(t$State),c(5,2,3,4)]" value = ("replace" "value") t nil)
  = org-babel-execute:R("library(plyr)\nlibrary(Hmisc)\ng->tempg\n\n =                     =                    # = CV_untreated\nas.integer(tempg$state_region/10)->tempg$State.code.68\nf= actor(tempg$State.code.68)->tempg$State.code.68\ndata.frame(State=3D0,a= djusted_cv=3D0)->e\n\nfor (i in c(1:35)) {\n   =  subset(tempg,as.numeric(tempg$State.code.68)=3D=3Di)->dd\n =   =  wtd.var(dd$adj_cal,weight=3Ddd$weight)^0.5/wtd.mean(dd$adj_cal,weigh= t=3Ddd$weight)->cvs\n   =  data.frame(State=3Di,adjusted_cv=3Dcvs)->e1\n   =  rbind(e,e1)->e\n}\n\nddply(tempg,.(State.code.68),summarise,value= =3Dwtd.mean(adj_cal,weight))->s1\n\ndata.frame(State=3D99,adjusted_cv=3D= 0)->f2\nwtd.var(tempg$adj_cal,weight=3Dtempg$weight)^0.5/wtd.mean(tempg= $adj_cal,weight=3Dtempg$weight)->f2[1,2]\nrbind(e,f2)->cv1\n\n =                     =                    # = CV_grouped = data\nddply(tempg,.(sex,agegroup,fractile_adj),summarise,calories=3Dwtd.me= an(adj_cal,weight))->l1\nddply(tempg,.(sex,agegroup,fractile_adj),summa= rise,weight=3Dsum(weight))->w\n\nmerge(w,l1,by=3Dc(\"sex\",\"agegroup\"= ,\"fractile_adj\"))->l1\n\nddply(tempg,.(fractile_adj_state,State.code.= 68,agegroup,sex),summarise,value=3Dwtd.mean(adj_cal,weight))->s3\n\nddp= ly(tempg,.(fractile_adj_state,State.code.68,agegroup,sex),summarise,sum_we= ight=3Dsum(weight))->sw\n\nmerge(s3,sw,by=3Dc(\"fractile_adj_state\",\"= State.code.68\",\"agegroup\",\"sex\"))->s3\n\nfactor(s3$State.code.68)-= >s3$State.code.68\n\ndata.frame(State=3D99,grouped_cv=3Dwtd.var(l1$calo= ries,weight=3Dl1$weight)^0.5/wtd.mean(l1$calories,weight=3Dl1$weight))->= ;cv3\n\nfor (i in c(1:35)) {\n   =  subset(s3,as.numeric(s3$State.code.68)=3D=3Di)->s3sub\n   =  data.frame(State=3Di,grouped_cv=3Dwtd.var(s3sub$value,s3sub$sum_weig= ht)^0.5/wtd.mean(s3sub$value,s3sub$sum_weight))->t1\n   =  rbind(cv3,t1)->cv3\n}\n\n# CV_from regression = model\nregdata->p\nexp(predict.lm(reg))->p$predicted_cal\n\ndata.fra= me(State=3D99,predicted_cv=3Dwtd.var(p$predicted_cal,weight=3Dp$weight)^0.= 5/wtd.mean(p$predicted_cal,weight=3Dp$weight),adjr2=3Dsummary(reg)$adj.r.s= quared)->cv2\n\n\n#data.frame(State=3D0,predicted_cv=3D0,adjr2=3D0)->= ;e\n\nfor (i in c(1:35)) {\n   =  subset(regdata,as.numeric(p$State.code.68)=3D=3Di)->dd\n   =  factor(dd$state_region)->dd$state_region\nfmla <- = as.formula(\n         = ifelse(length(levels(dd$state_region))=3D=3D1,\"log_cal~sector+sex+AgeChil= d+AgeAdult+foodprice+log(MPCE)\",\"log_cal~sector+sex+AgeChild+AgeAdult+fo= odprice+log(MPCE)+state_region\"))\n\n\n   =  lm(fmla,data=3Ddd,weights=3Dweight)->regstate\n   =  exp(predict.lm(regstate))->dd$predicted_cal\n   =  wtd.var(dd$predicted_cal,weight=3Ddd$weight)^0.5/wtd.mean(dd$predict= ed_cal,weight=3Ddd$weight)->cvs\n   =  data.frame(State=3Di,predicted_cv=3Dcvs,adjr2=3Dsummary(regstate)$ad= j.r.squared)->e1\n   =  rbind(cv2,e1)->cv2\n}\n\nsubset(cv2,select=3D-adjr2)->cv2\n\nm= erge(cv1,cv3,by=3D\"State\")->t\nmerge(t,cv2,by=3D\"State\")->t\nmer= ge(t,statecode,by.x=3D\"State\",by.y=3D\"State.code.68\",all.x=3DTRUE)->= ;t\nt$State.68[t$State=3D=3D99]<-\"India\"\nround(t$grouped_cv,4)->t= $grouped_cv\nround(t$adjusted_cv,4)->t$adjusted_cv\nround(t$predicted_c= v,4)->t$predicted_cv\nnames(t)<-c(\"State.code.68\",\"CV = (unit-level data)\",\"CV (grouped data)\",\"CV (based on regression = model)\",\"State\")\nt->finvar\nt[order(t$State),c(5,2,3,4)]" = ((:colname-names) (:rowname-names) (:result-params "replace" "value") = (:result-type . value) (:comments . "") (:shebang . "") (:cache . "no") = (:padline . "") (:noweb . "no") (:tangle . "no") (:exports . "results") = (:results . "replace value") (:hlines . "no") (:session . "type2") = (:colnames . "yes") (:hline . "yes")))
  = org-babel-execute-src-block(nil)
  = org-babel-execute-src-block-maybe()
  = org-babel-execute-maybe()
  = org-babel-execute-safely-maybe()
  = run-hook-with-args-until-success(org-babel-execute-safely-maybe)
  org-ctrl-c-ctrl-c(nil)
  = call-interactively(org-ctrl-c-ctrl-c nil nil)
  = command-execute(org-ctrl-c-ctrl-c)

On 28-May-2016, at 10:31 pm, Charles C. Berry <ccberry@ucsd.edu> = wrote:


p.s. one more thing - below

On Sat, 28 May 2016, Charles C. Berry = wrote:

On Sat, 28 May 2016, William Denton wrote:

On 28 May = 2016, Vikas Rawal wrote:
Thanks John. Appreciate that you cared to respond to such a = vague query. I am at a loss with this one. It does not happen all the = time. I think it happens when I am processing large datasets, and CPUs = and RAM of my system are struggling to keep up. But I could be wrong.
I've had the same kind of thing happen---but C-g = (sometimes many) to kill the command, then rerunning, usually works = without any trouble. Some strange combination of CPU and RAM and all = that, the kind of thing that's not easily reproducible.

Try this: customize = `debug-on-quit' to `t' (and set for current session).

Then when you have to quit via C-g, you will get a backtrace = showing where the process was hanging and how it got there. This might = be helpful in figuring out what is going on.

Run your code and when you finally have to C-g out copy the = *Backtrace* buffer and report it back here (or on the ESS list if = appropriate).


After you copy the buffer, you should type 'q' = in the *Backtrace* buffer to finish up or you may have some odd messages = and hangups afterwards.

Chuck

= --Apple-Mail=_CD401725-A451-45DD-898A-584282E2D51C--