Re: [O] Trouble evaluating R source code blocks with C-c C-c

2016-05-30 Thread Charles C. Berry

On Mon, 30 May 2016, Vikas Rawal wrote:


Thanks.

The code still seems to freeze.

The backtrace now is.



OK, let me abbreviate this by cutting off the ends of long lines:


Debugger entered--Lisp error: (quit)
 process-send-string(# ".ess.eval(\"lm(log_cal~sector+ [...]
 ess-send-string--fallback(# ".ess.eval(\"lm(log_cal~  [...]
 ess-send-string(# ".ess.eval(\"lm(log_cal~sector+sex+ [...]
 ess-tracebug-send-region(# 1 1183 nil "Eval buffer" buffer)
 ess-send-region(# 1 1183 nil "Eval buffer" buffer)
 ess-eval-region(1 1183 nil "Eval buffer" buffer)
 ess-eval-buffer(nil)
 org-babel-R-evaluate-session("type2" "lm(log_cal~sector+sex+AgeChild+ [...]
 org-babel-R-evaluate("type2" "lm(log_cal~sector+sex+AgeChild+AgeAdult+ [...]
 org-babel-execute:R("lm(log_cal~sector+sex+AgeChild+AgeAdult+foodprice+  [...]
 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)



And what you had previously was [using some abbreviations]:


sit-for(0.25)
org-babel-comint-eval-invisibly-and-wait-for-file("type2" [filename] [R command 
string] [...]
org-babel-R-evaluate-session("type2" [R command string] ...
org-babel-R-evaluate("type2" [R command string] ...
org-babel-execute:R( [R command string] ...
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)

What you can see is that everything is the same right up to this line

 `org-babel-R-evaluate-session(...'

but in the top (most recent) version ess-* functions are shown right
up to process-send-string, which means that ess is still trying to
complete its work. In the older (bottom) version ess is done and babel
is waiting for the resulting file.

This makes me wonder what R is doing.

Can you check the activity monitor (you are on OS X, right?) and see
what is happening? If the R code takes a long time to run and the R
process is chewing up CPU or reading from/writing to disk this would
explain it.

If that isn't it, you might try to put in some checkpoints to see how
far the R code got. I'd put something like

cat("Starting",file="progress.txt")

at the top of your src code and

   cat(".",file="progress.txt",append=TRUE)

after every line and

   cat("Done\n",file="progress.txt",append=TRUE)

after the last command at the very bottom.

Then if the R code hangs somewhere you can open `progress.txt', count
up the dots, and see where it got to.

If that does not appeal to you, then profiling the R code might
do. see ?Rprof.

Finally, you aren't doing something exotic - like trying to run src
blocks from a local buffer in a remote session - are you? If so, that
adds a layer of complexity that needs discussion.

HTH,

Chuck



Re: [O] Trouble evaluating R source code blocks with C-c C-c

2016-05-30 Thread Vikas Rawal
Thanks.

The code still seems to freeze.

The backtrace now is.

Debugger entered--Lisp error: (quit)
  process-send-string(# 
".ess.eval(\"lm(log_cal~sector+sex+AgeChild+AgeAdult+foodprice+log(MPCE)+state_region,data=regdata,weights=weight)->reg\nlm(adj_cal~sector+sex+AgeChild+AgeAdult+foodprice+log(MPCE)+state_region,data=regdata,weights=weight)->reg.1\nlibrary(car)\nlibrary(lmtest)\nlibrary(sandwich)\ncov1
 <- vcovHC(reg, type = \\\"HC1\\\")\nrobust_se<- 
sqrt(diag(cov1))\n\ncov2 <- vcovHC(reg.1, type = 
\\\"HC1\\\")\nrobust_se2<- sqrt(diag(cov2))\n   
 # Adjust F statistic\nwald_results <- waldtest(reg, vcov = 
cov1)\nwald_results2 <- waldtest(reg.1, vcov = cov2)\n\n
#coeftest(reg, vcov = hccm)->reg2\noptions(scipen = 
999)\nlibrary(stargazer)\nstargazer(reg.1,reg,\n  align=TRUE,\n 
 title=\\\"Regression of per capita calorie intake with monthly per capita 
consumer expenditure, and demographic and other socio-economic variables\\\",\n 
 dep.var.labels = c(\\\"Per capita calorie intake\\\",\\\"Log of per 
capita calorie intake\\\"),\n  se=list(NULL,robust_se,robust_se2),\n
  omit=\\\"state\\\",\n  model.numbers=FALSE,\n  report = 
\\\"vct*\\\",\n  single.row=TRUE,\n  omit.labels = \\\"State 
and region dummies\\\")\", visibly = FALSE, output = TRUE, file = 
'/var/folders/hj/hqfjch716qg5php160jbtfghgn/T/unknown!53134yFm')\n")
  ess-send-string--fallback(# 
".ess.eval(\"lm(log_cal~sector+sex+AgeChild+AgeAdult+foodprice+log(MPCE)+state_region,data=regdata,weights=weight)->reg\nlm(adj_cal~sector+sex+AgeChild+AgeAdult+foodprice+log(MPCE)+state_region,data=regdata,weights=weight)->reg.1\nlibrary(car)\nlibrary(lmtest)\nlibrary(sandwich)\ncov1
 <- vcovHC(reg, type = \\\"HC1\\\")\nrobust_se<- 
sqrt(diag(cov1))\n\ncov2 <- vcovHC(reg.1, type = 
\\\"HC1\\\")\nrobust_se2<- sqrt(diag(cov2))\n   
 # Adjust F statistic\nwald_results <- waldtest(reg, vcov = 
cov1)\nwald_results2 <- waldtest(reg.1, vcov = cov2)\n\n
#coeftest(reg, vcov = hccm)->reg2\noptions(scipen = 
999)\nlibrary(stargazer)\nstargazer(reg.1,reg,\n  align=TRUE,\n 
 title=\\\"Regression of per capita calorie intake with monthly per capita 
consumer expenditure, and demographic and other socio-economic variables\\\",\n 
 dep.var.labels = c(\\\"Per capita calorie intake\\\",\\\"Log of per 
capita calorie intake\\\"),\n  se=list(NULL,robust_se,robust_se2),\n
  omit=\\\"state\\\",\n  model.numbers=FALSE,\n  report = 
\\\"vct*\\\",\n  single.row=TRUE,\n  omit.labels = \\\"State 
and region dummies\\\")\", visibly = FALSE, output = TRUE, file = 
'/var/folders/hj/hqfjch716qg5php160jbtfghgn/T/unknown!53134yFm')\n" nil 
"Eval buffer")
  ess-send-string(# 
".ess.eval(\"lm(log_cal~sector+sex+AgeChild+AgeAdult+foodprice+log(MPCE)+state_region,data=regdata,weights=weight)->reg\nlm(adj_cal~sector+sex+AgeChild+AgeAdult+foodprice+log(MPCE)+state_region,data=regdata,weights=weight)->reg.1\nlibrary(car)\nlibrary(lmtest)\nlibrary(sandwich)\ncov1
 <- vcovHC(reg, type = \\\"HC1\\\")\nrobust_se<- 
sqrt(diag(cov1))\n\ncov2 <- vcovHC(reg.1, type = 
\\\"HC1\\\")\nrobust_se2<- sqrt(diag(cov2))\n   
 # Adjust F statistic\nwald_results <- waldtest(reg, vcov = 
cov1)\nwald_results2 <- waldtest(reg.1, vcov = cov2)\n\n
#coeftest(reg, vcov = hccm)->reg2\noptions(scipen = 
999)\nlibrary(stargazer)\nstargazer(reg.1,reg,\n  align=TRUE,\n 
 title=\\\"Regression of per capita calorie intake with monthly per capita 
consumer expenditure, and demographic and other socio-economic variables\\\",\n 
 dep.var.labels = c(\\\"Per capita calorie intake\\\",\\\"Log of per 
capita calorie intake\\\"),\n  se=list(NULL,robust_se,robust_se2),\n
  omit=\\\"state\\\",\n  model.numbers=FALSE,\n  report = 
\\\"vct*\\\",\n  single.row=TRUE,\n  omit.labels = \\\"State 
and region dummies\\\")\", visibly = FALSE, output = TRUE, file = 
'/var/folders/hj/hqfjch716qg5php160jbtfghgn/T/unknown!53134yFm')\n" nil 
"Eval buffer")
  ess-tracebug-send-region(# 1 1183 nil "Eval buffer" buffer)
  ess-send-region(# 1 1183 nil "Eval buffer" buffer)
  ess-eval-region(1 1183 nil "Eval buffer" buffer)
  ess-eval-buffer(nil)
  org-babel-R-evaluate-session("type2" 
"lm(log_cal~sector+sex+AgeChild+AgeAdult+foodprice+log(MPCE)+state_region,data=regdata,weights=weight)->reg\nlm(adj_cal~sector+sex+AgeChild+AgeAdult+foodprice+log(MPCE)+state_region,data=regdata,weights=weight)->reg.1\nlibrary(car)\nlibrary(lmtest)\nlibrary(sandwich)\ncov1
 <- vcovHC(reg, type = \"HC1\")\nrobust_se<- 

Re: [O] Trouble evaluating R source code blocks with C-c C-c

2016-05-29 Thread Charles C. Berry

On Sun, 29 May 2016, Vikas Rawal wrote:





Vikas, can you edit the `sit-for' to `sleep-for' in

`org-babel-comint-eval-invisibly-and-wait-for-file'

and `eval-defun' the result and see if that has any effect?






Sorry, given my limited ability with lisp, I do not really
understand. Could you please spell out what do I have to do.


Vikas,

Copy the src-block at bottom to a *.org file or org-mode buffer. Then
execute it with `C-c C-c y'.

You should see

#+RESULTS:
: org-babel-comint-eval-invisibly-and-wait-for-file

appear afterwards.

Then try running your R code to see if it works reliably.

Does that seem to fix it?

If not, please check the session buffer to see if there were any
warnings or errors.

Chuck


#+BEGIN_SRC emacs-lisp
(defun org-babel-comint-eval-invisibly-and-wait-for-file
  (buffer file string  period)
"Evaluate STRING in BUFFER invisibly.
Don't return until FILE exists.  Code in STRING must ensure that
FILE exists at end of evaluation."
  (unless (org-babel-comint-buffer-livep buffer)
  (error "Buffer %s does not exist or has no process" buffer))
(if (file-exists-p file) (delete-file file))
   (process-send-string
  (get-buffer-process buffer)
 (if (= (aref string (1- (length string))) ?\n) string (concat string 
"\n")))
;; From Tramp 2.1.19 the following cache flush is not necessary
  (if (file-remote-p default-directory)
  (with-parsed-tramp-file-name default-directory nil
 (tramp-flush-directory-property v "")))
(while (not (file-exists-p file)) (sleep-for (or period 0.25

#+END_SRC



Re: [O] Trouble evaluating R source code blocks with C-c C-c

2016-05-29 Thread Vikas Rawal

> 
> Vikas, can you edit the `sit-for' to `sleep-for' in
> 
> `org-babel-comint-eval-invisibly-and-wait-for-file'
> 
> and `eval-defun' the result and see if that has any effect?
> 

Sorry, given my limited ability with lisp, I do not really understand. Could 
you please spell out what do I have to do.

Much appreciate your help.

Vikas


Re: [O] Trouble evaluating R source code blocks with C-c C-c

2016-05-29 Thread Charles C. Berry

On Sun, 29 May 2016, Vikas Rawal wrote:


And this time it has this additional line:   
run-hook-with-args-until-success(org-babel-execute-safely-maybe)


Actually, I saw that line in your previous posting.

But this may help:



--

 sit-for(0.25)
 org-babel-comint-eval-invisibly-and-wait-for-file("type2"


[rest deleted]


`sit-for' is in this loop:

`(while (not (file-exists-p file)) (sit-for (or period 0.25)))'

which suggests that the file to which the results should be written is not 
being created or there is an issue with `sit-for'.


Does anyone know why `sit-for' is used here rather than `sleep-for'?

I ask because I see that `sit-for' because it seems to me that `sleep-for' 
would be enough and `sit-for' has inline comments that suggest some 
unresolved issues.


Vikas, can you edit the `sit-for' to `sleep-for' in

`org-babel-comint-eval-invisibly-and-wait-for-file'

and `eval-defun' the result and see if that has any effect?

Chuck



Re: [O] Trouble evaluating R source code blocks with C-c C-c

2016-05-29 Thread Vikas Rawal
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/hqfjch716qg5php160jbtfghgn/T/babel-53134TSq/R-53134vJF" 
"{\nfunction(object,transfer.file) {\nobject\ninvisible(\n  
  if (\ninherits(\ntry(\n   
 {\ntfile<-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/hqfjch716qg5php160jbtfghgn/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)) {\nsubset(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)) {\nsubset(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)) {\nsubset(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)) {\nsubset(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

Re: [O] Trouble evaluating R source code blocks with C-c C-c

2016-05-29 Thread Vikas Rawal
Does this back-trace say anything?

  sit-for(0.25)
  org-babel-comint-eval-invisibly-and-wait-for-file("type2" 
"/var/folders/hj/hqfjch716qg5php160jbtfghgn/T/babel-53134TSq/R-53134IWW" 
"{\nfunction(object,transfer.file) {\nobject\ninvisible(\n  
  if (\ninherits(\ntry(\n   
 {\ntfile<-tempfile()\n 
   write.table(object, file=tfile, sep=\"\\t\",\n   
 na=\"nil\",row.names=FALSE,col.names=FALSE,\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/hqfjch716qg5php160jbtfghgn/T/babel-53134TSq/R-53134IWW\")")
  org-babel-R-evaluate-session("type2" 
"lm(log_cal~sector+SocialGroup+sex+AgeChild+AgeAdult+foodprice+log(MPCE)+state_region,data=regdata,weights=weight)->reg\nlm(adj_cal~sector+SocialGroup+sex+AgeChild+AgeAdult+foodprice+log(MPCE)+state_region,data=regdata,weights=weight)->reg.1\nlibrary(car)\nlibrary(lmtest)\nlibrary(sandwich)\ncov1
 <- vcovHC(reg, type = \"HC1\")\nrobust_se<- 
sqrt(diag(cov1))\n\ncov2 <- vcovHC(reg.1, type = \"HC1\")\nrobust_se2   
 <- sqrt(diag(cov2))\n# Adjust F 
statistic\nwald_results <- waldtest(reg, vcov = cov1)\nwald_results2 <- 
waldtest(reg.1, vcov = cov2)\n\n
#coeftest(reg, vcov = hccm)->reg2\noptions(scipen = 
999)\nlibrary(stargazer)\nstargazer(reg.1,reg,\n  align=TRUE,\n 
 title=\"Regression of per capita calorie intake with monthly per capita 
consumer expenditure, and demographic and other socio-economic variables\",\n   
   dep.var.labels = c(\"Per capita calorie intake\",\"Log of per capita 
calorie intake\"),\n  se=list(NULL,robust_se,robust_se2),\n  
omit=\"state\",\n  model.numbers=FALSE,\n  report = \"vct*\",\n 
 single.row=TRUE,\n  omit.labels = \"State and region 
dummies\")" value ("replace" "scalar" "latex") nil nil)
  org-babel-R-evaluate("type2" 
"lm(log_cal~sector+SocialGroup+sex+AgeChild+AgeAdult+foodprice+log(MPCE)+state_region,data=regdata,weights=weight)->reg\nlm(adj_cal~sector+SocialGroup+sex+AgeChild+AgeAdult+foodprice+log(MPCE)+state_region,data=regdata,weights=weight)->reg.1\nlibrary(car)\nlibrary(lmtest)\nlibrary(sandwich)\ncov1
 <- vcovHC(reg, type = \"HC1\")\nrobust_se<- 
sqrt(diag(cov1))\n\ncov2 <- vcovHC(reg.1, type = \"HC1\")\nrobust_se2   
 <- sqrt(diag(cov2))\n# Adjust F 
statistic\nwald_results <- waldtest(reg, vcov = cov1)\nwald_results2 <- 
waldtest(reg.1, vcov = cov2)\n\n
#coeftest(reg, vcov = hccm)->reg2\noptions(scipen = 
999)\nlibrary(stargazer)\nstargazer(reg.1,reg,\n  align=TRUE,\n 
 title=\"Regression of per capita calorie intake with monthly per capita 
consumer expenditure, and demographic and other socio-economic variables\",\n   
   dep.var.labels = c(\"Per capita calorie intake\",\"Log of per capita 
calorie intake\"),\n  se=list(NULL,robust_se,robust_se2),\n  
omit=\"state\",\n  model.numbers=FALSE,\n  report = \"vct*\",\n 
 single.row=TRUE,\n  omit.labels = \"State and region 
dummies\")" value ("replace" "scalar" "latex") nil nil)
  
org-babel-execute:R("lm(log_cal~sector+SocialGroup+sex+AgeChild+AgeAdult+foodprice+log(MPCE)+state_region,data=regdata,weights=weight)->reg\nlm(adj_cal~sector+SocialGroup+sex+AgeChild+AgeAdult+foodprice+log(MPCE)+state_region,data=regdata,weights=weight)->reg.1\nlibrary(car)\nlibrary(lmtest)\nlibrary(sandwich)\ncov1
 <- vcovHC(reg, type = \"HC1\")\nrobust_se<- 
sqrt(diag(cov1))\n\ncov2 <- vcovHC(reg.1, type = \"HC1\")\nrobust_se2   
 <- sqrt(diag(cov2))\n# Adjust F 
statistic\nwald_results <- waldtest(reg, vcov = cov1)\nwald_results2 <- 
waldtest(reg.1, vcov = cov2)\n\n
#coeftest(reg, vcov = hccm)->reg2\noptions(scipen = 
999)\nlibrary(stargazer)\nstargazer(reg.1,reg,\n  align=TRUE,\n 
 title=\"Regression of per capita calorie intake with monthly per capita 
consumer expenditure, and demographic and other socio-economic variables\",\n   
   dep.var.labels = c(\"Per capita calorie intake\",\"Log of per capita 
calorie intake\"),\n  se=list(NULL,robust_se,robust_se2),\n  
omit=\"state\",\n  model.numbers=FALSE,\n  report = \"vct*\",\n 
 

Re: [O] Trouble evaluating R source code blocks with C-c C-c

2016-05-28 Thread Vikas Rawal

> On 28-May-2016, at 7:57 pm, 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.
> 

This seems to be write. Upgrading ess did not help.

The odd thing is that running the same code by doing C-‘ to open a temporary R 
buffer and running to code from there works fine. But then I come back to the 
org buffer, C-c C-c, and the whole thing just freezes. The R session shows that 
the code is running. I have to use C-g in the org-buffer, which releases the 
org buffer, and C-c several times in the R session, to stop the commands. If I 
have waited enough, doing C-c C-c at the end in the R session ends the command 
and actually shows the output of the last command in R buffer. Which means that 
the last command had been completed. But the output was not inserted in the org 
buffer, and R was going on doing something.

Let me try ‘debug-on-quit'

Vikas


Re: [O] Trouble evaluating R source code blocks with C-c C-c

2016-05-28 Thread Charles C. Berry


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




Re: [O] Trouble evaluating R source code blocks with C-c C-c

2016-05-28 Thread Charles C. Berry

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).


Chuck



Re: [O] Trouble evaluating R source code blocks with C-c C-c

2016-05-28 Thread William Denton

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.


Relatedly, sometimes if I have ":results output" for one block and then 
":results values" for the next one, the second block picks up the output from 
the first one.  But then other times not!  Seems to depend on how intensive the 
R work is.


Bill
--
William Denton :: Toronto, Canada :: https://www.miskatonic.org/
Caveat lector.



Re: [O] Trouble evaluating R source code blocks with C-c C-c

2016-05-28 Thread Vikas Rawal
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.

Let me take your advice and upgrade ESS. Hope that would help.

Vikas


> On 27-May-2016, at 12:22 am, John Hendy  wrote:
> 
> Could you give a minimal example? The behavior does ring a bell, but I
> can't recall what the solution might have been. I'd be happy to try
> and reproduce if you'd like.
> 
> I think my typical go-to is to wipe ESS and re-download/make... That's
> all I'm good for without more info.
> 
> 
> Sorry!
> John
> 
> On Thu, May 26, 2016 at 9:33 AM, Vikas Rawal
>  wrote:
>> I face a strange problem with evaluating R source code blocks. Occasionally, 
>> they take much longer to produce the results when I try to evaluate them 
>> with C-c C-c. On the other hand, if I do C-c ‘, go to a temporary R buffer, 
>> and evaluate the code, everything works fine. In face, when I use C-c C-c, 
>> the session would sometimes get stuck. Then I have to stop the process using 
>> C-g, I find that the code had run in R, but the result was not being 
>> inserted in Org buffer.
>> 
>> Has anyone else faced this problem?
>> 
>> I am on OS-X, Emacs 24, Org-mode version 8.3.4 (release_8.3.4-748-g7e320e, 
>> and ess-version: 15.09-devel [elpa: 20150913.638]
>> 
>> Vikas
>> 
>> 
>> 
>> 




Re: [O] Trouble evaluating R source code blocks with C-c C-c

2016-05-26 Thread John Hendy
Could you give a minimal example? The behavior does ring a bell, but I
can't recall what the solution might have been. I'd be happy to try
and reproduce if you'd like.

I think my typical go-to is to wipe ESS and re-download/make... That's
all I'm good for without more info.


Sorry!
John

On Thu, May 26, 2016 at 9:33 AM, Vikas Rawal
 wrote:
> I face a strange problem with evaluating R source code blocks. Occasionally, 
> they take much longer to produce the results when I try to evaluate them with 
> C-c C-c. On the other hand, if I do C-c ‘, go to a temporary R buffer, and 
> evaluate the code, everything works fine. In face, when I use C-c C-c, the 
> session would sometimes get stuck. Then I have to stop the process using C-g, 
> I find that the code had run in R, but the result was not being inserted in 
> Org buffer.
>
> Has anyone else faced this problem?
>
> I am on OS-X, Emacs 24, Org-mode version 8.3.4 (release_8.3.4-748-g7e320e, 
> and ess-version: 15.09-devel [elpa: 20150913.638]
>
> Vikas
>
>
>
>