Thanks. The code still seems to freeze.
The backtrace now is. Debugger entered--Lisp error: (quit) process-send-string(#<process R> ".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/hqfjch716qg5php160jbtfgh0000gn/T/unknown!53134yFm')\n") ess-send-string--fallback(#<process R> ".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/hqfjch716qg5php160jbtfgh0000gn/T/unknown!53134yFm')\n" nil "Eval buffer") ess-send-string(#<process R> ".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/hqfjch716qg5php160jbtfgh0000gn/T/unknown!53134yFm')\n" nil "Eval buffer") ess-tracebug-send-region(#<process R> 1 1183 nil "Eval buffer" buffer) ess-send-region(#<process R> 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 <- 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+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\")" value ("replace" "scalar" "latex") nil nil) org-babel-execute:R("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\")" ((:colname-names) (:rowname-names) (:result-params "replace" "scalar" "latex") (:result-type . value) (:comments . "") (:shebang . "") (:cache . "no") (:padline . "") (:noweb . "no") (:tangle . "no") (:exports . "results") (:results . "replace scalar latex") (:hlines . "no") (:session . "type2"))) 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 30-May-2016, at 6:48 am, Charles C. Berry <ccbe...@ucsd.edu> wrote: > > 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 &optional 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