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-53134vJF"
"{\n function(object,transfer.file) {\n object\n invisible(\n
if (\n inherits(\n try(\n
{\n tfile<-tempfile()\n
write.table(object, file=tfile, sep=\"\\t\",\n
na=\"nil\",row.names=FALSE,col.names=TRUE,\n
quote=FALSE)\n
file.rename(tfile,transfer.file)\n },\n
silent=TRUE),\n \"try-error\"))\n {\n
if(!file.exists(transfer.file))\n
file.create(transfer.file)\n }\n )\n
}\n}(object=.Last.value,transfer.file=\"/var/folders/hj/hqfjch716qg5php160jbtfgh0000gn/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\nfactor(tempg$State.code.68)->tempg$State.code.68\ndata.frame(State=0,adjusted_cv=0)->e\n\nfor
(i in c(1:35)) {\n subset(tempg,as.numeric(tempg$State.code.68)==i)->dd\n
wtd.var(dd$adj_cal,weight=dd$weight)^0.5/wtd.mean(dd$adj_cal,weight=dd$weight)->cvs\n
data.frame(State=i,adjusted_cv=cvs)->e1\n
rbind(e,e1)->e\n}\n\nddply(tempg,.(State.code.68),summarise,value=wtd.mean(adj_cal,weight))->s1\n\ndata.frame(State=99,adjusted_cv=0)->f2\nwtd.var(tempg$adj_cal,weight=tempg$weight)^0.5/wtd.mean(tempg$adj_cal,weight=tempg$weight)->f2[1,2]\nrbind(e,f2)->cv1\n\n
# CV_grouped
data\nddply(tempg,.(sex,agegroup,fractile_adj),summarise,calories=wtd.mean(adj_cal,weight))->l1\nddply(tempg,.(sex,agegroup,fractile_adj),summarise,weight=sum(weight))->w\n\nmerge(w,l1,by=c(\"sex\",\"agegroup\",\"fractile_adj\"))->l1\n\nddply(tempg,.(fractile_adj_state,State.code.68,agegroup,sex),summarise,value=wtd.mean(adj_cal,weight))->s3\n\nddply(tempg,.(fractile_adj_state,State.code.68,agegroup,sex),summarise,sum_weight=sum(weight))->sw\n\nmerge(s3,sw,by=c(\"fractile_adj_state\",\"State.code.68\",\"agegroup\",\"sex\"))->s3\n\nfactor(s3$State.code.68)->s3$State.code.68\n\ndata.frame(State=99,grouped_cv=wtd.var(l1$calories,weight=l1$weight)^0.5/wtd.mean(l1$calories,weight=l1$weight))->cv3\n\nfor
(i in c(1:35)) {\n subset(s3,as.numeric(s3$State.code.68)==i)->s3sub\n
data.frame(State=i,grouped_cv=wtd.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(State=99,predicted_cv=wtd.var(p$predicted_cal,weight=p$weight)^0.5/wtd.mean(p$predicted_cal,weight=p$weight),adjr2=summary(reg)$adj.r.squared)->cv2\n\n\n#data.frame(State=0,predicted_cv=0,adjr2=0)->e\n\nfor
(i in c(1:35)) {\n subset(regdata,as.numeric(p$State.code.68)==i)->dd\n
factor(dd$state_region)->dd$state_region\nfmla <- as.formula(\n
ifelse(length(levels(dd$state_region))==1,\"log_cal~sector+sex+AgeChild+AgeAdult+foodprice+log(MPCE)\",\"log_cal~sector+sex+AgeChild+AgeAdult+foodprice+log(MPCE)+state_region\"))\n\n\n
lm(fmla,data=dd,weights=weight)->regstate\n
exp(predict.lm(regstate))->dd$predicted_cal\n
wtd.var(dd$predicted_cal,weight=dd$weight)^0.5/wtd.mean(dd$predicted_cal,weight=dd$weight)->cvs\n
data.frame(State=i,predicted_cv=cvs,adjr2=summary(regstate)$adj.r.squared)->e1\n
rbind(cv2,e1)->cv2\n}\n\nsubset(cv2,select=-adjr2)->cv2\n\nmerge(cv1,cv3,by=\"State\")->t\nmerge(t,cv2,by=\"State\")->t\nmerge(t,statecode,by.x=\"State\",by.y=\"State.code.68\",all.x=TRUE)->t\nt$State.68[t$State==99]<-\"India\"\nround(t$grouped_cv,4)->t$grouped_cv\nround(t$adjusted_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\nfactor(tempg$State.code.68)->tempg$State.code.68\ndata.frame(State=0,adjusted_cv=0)->e\n\nfor
(i in c(1:35)) {\n subset(tempg,as.numeric(tempg$State.code.68)==i)->dd\n
wtd.var(dd$adj_cal,weight=dd$weight)^0.5/wtd.mean(dd$adj_cal,weight=dd$weight)->cvs\n
data.frame(State=i,adjusted_cv=cvs)->e1\n
rbind(e,e1)->e\n}\n\nddply(tempg,.(State.code.68),summarise,value=wtd.mean(adj_cal,weight))->s1\n\ndata.frame(State=99,adjusted_cv=0)->f2\nwtd.var(tempg$adj_cal,weight=tempg$weight)^0.5/wtd.mean(tempg$adj_cal,weight=tempg$weight)->f2[1,2]\nrbind(e,f2)->cv1\n\n
# CV_grouped
data\nddply(tempg,.(sex,agegroup,fractile_adj),summarise,calories=wtd.mean(adj_cal,weight))->l1\nddply(tempg,.(sex,agegroup,fractile_adj),summarise,weight=sum(weight))->w\n\nmerge(w,l1,by=c(\"sex\",\"agegroup\",\"fractile_adj\"))->l1\n\nddply(tempg,.(fractile_adj_state,State.code.68,agegroup,sex),summarise,value=wtd.mean(adj_cal,weight))->s3\n\nddply(tempg,.(fractile_adj_state,State.code.68,agegroup,sex),summarise,sum_weight=sum(weight))->sw\n\nmerge(s3,sw,by=c(\"fractile_adj_state\",\"State.code.68\",\"agegroup\",\"sex\"))->s3\n\nfactor(s3$State.code.68)->s3$State.code.68\n\ndata.frame(State=99,grouped_cv=wtd.var(l1$calories,weight=l1$weight)^0.5/wtd.mean(l1$calories,weight=l1$weight))->cv3\n\nfor
(i in c(1:35)) {\n subset(s3,as.numeric(s3$State.code.68)==i)->s3sub\n
data.frame(State=i,grouped_cv=wtd.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(State=99,predicted_cv=wtd.var(p$predicted_cal,weight=p$weight)^0.5/wtd.mean(p$predicted_cal,weight=p$weight),adjr2=summary(reg)$adj.r.squared)->cv2\n\n\n#data.frame(State=0,predicted_cv=0,adjr2=0)->e\n\nfor
(i in c(1:35)) {\n subset(regdata,as.numeric(p$State.code.68)==i)->dd\n
factor(dd$state_region)->dd$state_region\nfmla <- as.formula(\n
ifelse(length(levels(dd$state_region))==1,\"log_cal~sector+sex+AgeChild+AgeAdult+foodprice+log(MPCE)\",\"log_cal~sector+sex+AgeChild+AgeAdult+foodprice+log(MPCE)+state_region\"))\n\n\n
lm(fmla,data=dd,weights=weight)->regstate\n
exp(predict.lm(regstate))->dd$predicted_cal\n
wtd.var(dd$predicted_cal,weight=dd$weight)^0.5/wtd.mean(dd$predicted_cal,weight=dd$weight)->cvs\n
data.frame(State=i,predicted_cv=cvs,adjr2=summary(regstate)$adj.r.squared)->e1\n
rbind(cv2,e1)->cv2\n}\n\nsubset(cv2,select=-adjr2)->cv2\n\nmerge(cv1,cv3,by=\"State\")->t\nmerge(t,cv2,by=\"State\")->t\nmerge(t,statecode,by.x=\"State\",by.y=\"State.code.68\",all.x=TRUE)->t\nt$State.68[t$State==99]<-\"India\"\nround(t$grouped_cv,4)->t$grouped_cv\nround(t$adjusted_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\nfactor(tempg$State.code.68)->tempg$State.code.68\ndata.frame(State=0,adjusted_cv=0)->e\n\nfor
(i in c(1:35)) {\n subset(tempg,as.numeric(tempg$State.code.68)==i)->dd\n
wtd.var(dd$adj_cal,weight=dd$weight)^0.5/wtd.mean(dd$adj_cal,weight=dd$weight)->cvs\n
data.frame(State=i,adjusted_cv=cvs)->e1\n
rbind(e,e1)->e\n}\n\nddply(tempg,.(State.code.68),summarise,value=wtd.mean(adj_cal,weight))->s1\n\ndata.frame(State=99,adjusted_cv=0)->f2\nwtd.var(tempg$adj_cal,weight=tempg$weight)^0.5/wtd.mean(tempg$adj_cal,weight=tempg$weight)->f2[1,2]\nrbind(e,f2)->cv1\n\n
# CV_grouped
data\nddply(tempg,.(sex,agegroup,fractile_adj),summarise,calories=wtd.mean(adj_cal,weight))->l1\nddply(tempg,.(sex,agegroup,fractile_adj),summarise,weight=sum(weight))->w\n\nmerge(w,l1,by=c(\"sex\",\"agegroup\",\"fractile_adj\"))->l1\n\nddply(tempg,.(fractile_adj_state,State.code.68,agegroup,sex),summarise,value=wtd.mean(adj_cal,weight))->s3\n\nddply(tempg,.(fractile_adj_state,State.code.68,agegroup,sex),summarise,sum_weight=sum(weight))->sw\n\nmerge(s3,sw,by=c(\"fractile_adj_state\",\"State.code.68\",\"agegroup\",\"sex\"))->s3\n\nfactor(s3$State.code.68)->s3$State.code.68\n\ndata.frame(State=99,grouped_cv=wtd.var(l1$calories,weight=l1$weight)^0.5/wtd.mean(l1$calories,weight=l1$weight))->cv3\n\nfor
(i in c(1:35)) {\n subset(s3,as.numeric(s3$State.code.68)==i)->s3sub\n
data.frame(State=i,grouped_cv=wtd.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(State=99,predicted_cv=wtd.var(p$predicted_cal,weight=p$weight)^0.5/wtd.mean(p$predicted_cal,weight=p$weight),adjr2=summary(reg)$adj.r.squared)->cv2\n\n\n#data.frame(State=0,predicted_cv=0,adjr2=0)->e\n\nfor
(i in c(1:35)) {\n subset(regdata,as.numeric(p$State.code.68)==i)->dd\n
factor(dd$state_region)->dd$state_region\nfmla <- as.formula(\n
ifelse(length(levels(dd$state_region))==1,\"log_cal~sector+sex+AgeChild+AgeAdult+foodprice+log(MPCE)\",\"log_cal~sector+sex+AgeChild+AgeAdult+foodprice+log(MPCE)+state_region\"))\n\n\n
lm(fmla,data=dd,weights=weight)->regstate\n
exp(predict.lm(regstate))->dd$predicted_cal\n
wtd.var(dd$predicted_cal,weight=dd$weight)^0.5/wtd.mean(dd$predicted_cal,weight=dd$weight)->cvs\n
data.frame(State=i,predicted_cv=cvs,adjr2=summary(regstate)$adj.r.squared)->e1\n
rbind(cv2,e1)->cv2\n}\n\nsubset(cv2,select=-adjr2)->cv2\n\nmerge(cv1,cv3,by=\"State\")->t\nmerge(t,cv2,by=\"State\")->t\nmerge(t,statecode,by.x=\"State\",by.y=\"State.code.68\",all.x=TRUE)->t\nt$State.68[t$State==99]<-\"India\"\nround(t$grouped_cv,4)->t$grouped_cv\nround(t$adjusted_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 <[email protected]> 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