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: Mon, 30 May 2016 15:54:53 +0530 Message-ID: <84824898-5690-4956-A4C6-EC20872896A6@agrarianresearch.org> References: <2BE21056-50D3-49CE-8B0D-5467D182B7B5@agrarianresearch.org> <2E8B017B-F4AB-454D-81A1-E61F55F4F958@agrarianresearch.org> <5F862231-C04A-4BF6-8A2A-2377AF000374@agrarianresearch.org> Mime-Version: 1.0 (Mac OS X Mail 8.2 \(2104\)) Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:58140) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b7KNc-0007ZM-L3 for emacs-orgmode@gnu.org; Mon, 30 May 2016 06:25:10 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1b7KNY-0003yg-G6 for emacs-orgmode@gnu.org; Mon, 30 May 2016 06:25:04 -0400 Received: from mail-pf0-x233.google.com ([2607:f8b0:400e:c00::233]:34877) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b7KNY-0003ya-4c for emacs-orgmode@gnu.org; Mon, 30 May 2016 06:25:00 -0400 Received: by mail-pf0-x233.google.com with SMTP id g64so63898166pfb.2 for ; Mon, 30 May 2016 03:24:59 -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 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)+s= tate_region,data=3Dregdata,weights=3Dweight)->reg\nlm(adj_cal~sector+sex+A= geChild+AgeAdult+foodprice+log(MPCE)+state_region,data=3Dregdata,weights=3D= weight)->reg.1\nlibrary(car)\nlibrary(lmtest)\nlibrary(sandwich)\ncov1 = <- vcovHC(reg, type =3D \\\"HC1\\\")\nrobust_se <- = sqrt(diag(cov1))\n\ncov2 <- vcovHC(reg.1, type =3D = \\\"HC1\\\")\nrobust_se2 <- sqrt(diag(cov2))\n = # Adjust F statistic\nwald_results <- waldtest(reg, vcov = =3D cov1)\nwald_results2 <- waldtest(reg.1, vcov =3D cov2)\n\n = #coeftest(reg, vcov =3D = hccm)->reg2\noptions(scipen =3D = 999)\nlibrary(stargazer)\nstargazer(reg.1,reg,\n align=3DTRUE,\n = title=3D\\\"Regression of per capita calorie intake with = monthly per capita consumer expenditure, and demographic and other = socio-economic variables\\\",\n dep.var.labels =3D c(\\\"Per = capita calorie intake\\\",\\\"Log of per capita calorie intake\\\"),\n = se=3Dlist(NULL,robust_se,robust_se2),\n = omit=3D\\\"state\\\",\n model.numbers=3DFALSE,\n = report =3D \\\"vct*\\\",\n single.row=3DTRUE,\n = omit.labels =3D \\\"State and region dummies\\\")\", visibly =3D FALSE, = output =3D TRUE, file =3D = '/var/folders/hj/hqfjch716qg5php160jbtfgh0000gn/T/unknown!53134yFm')\n") ess-send-string--fallback(# = ".ess.eval(\"lm(log_cal~sector+sex+AgeChild+AgeAdult+foodprice+log(MPCE)+s= tate_region,data=3Dregdata,weights=3Dweight)->reg\nlm(adj_cal~sector+sex+A= geChild+AgeAdult+foodprice+log(MPCE)+state_region,data=3Dregdata,weights=3D= weight)->reg.1\nlibrary(car)\nlibrary(lmtest)\nlibrary(sandwich)\ncov1 = <- vcovHC(reg, type =3D \\\"HC1\\\")\nrobust_se <- = sqrt(diag(cov1))\n\ncov2 <- vcovHC(reg.1, type =3D = \\\"HC1\\\")\nrobust_se2 <- sqrt(diag(cov2))\n = # Adjust F statistic\nwald_results <- waldtest(reg, vcov = =3D cov1)\nwald_results2 <- waldtest(reg.1, vcov =3D cov2)\n\n = #coeftest(reg, vcov =3D = hccm)->reg2\noptions(scipen =3D = 999)\nlibrary(stargazer)\nstargazer(reg.1,reg,\n align=3DTRUE,\n = title=3D\\\"Regression of per capita calorie intake with = monthly per capita consumer expenditure, and demographic and other = socio-economic variables\\\",\n dep.var.labels =3D c(\\\"Per = capita calorie intake\\\",\\\"Log of per capita calorie intake\\\"),\n = se=3Dlist(NULL,robust_se,robust_se2),\n = omit=3D\\\"state\\\",\n model.numbers=3DFALSE,\n = report =3D \\\"vct*\\\",\n single.row=3DTRUE,\n = omit.labels =3D \\\"State and region dummies\\\")\", visibly =3D FALSE, = output =3D TRUE, file =3D = '/var/folders/hj/hqfjch716qg5php160jbtfgh0000gn/T/unknown!53134yFm')\n" = nil "Eval buffer") ess-send-string(# = ".ess.eval(\"lm(log_cal~sector+sex+AgeChild+AgeAdult+foodprice+log(MPCE)+s= tate_region,data=3Dregdata,weights=3Dweight)->reg\nlm(adj_cal~sector+sex+A= geChild+AgeAdult+foodprice+log(MPCE)+state_region,data=3Dregdata,weights=3D= weight)->reg.1\nlibrary(car)\nlibrary(lmtest)\nlibrary(sandwich)\ncov1 = <- vcovHC(reg, type =3D \\\"HC1\\\")\nrobust_se <- = sqrt(diag(cov1))\n\ncov2 <- vcovHC(reg.1, type =3D = \\\"HC1\\\")\nrobust_se2 <- sqrt(diag(cov2))\n = # Adjust F statistic\nwald_results <- waldtest(reg, vcov = =3D cov1)\nwald_results2 <- waldtest(reg.1, vcov =3D cov2)\n\n = #coeftest(reg, vcov =3D = hccm)->reg2\noptions(scipen =3D = 999)\nlibrary(stargazer)\nstargazer(reg.1,reg,\n align=3DTRUE,\n = title=3D\\\"Regression of per capita calorie intake with = monthly per capita consumer expenditure, and demographic and other = socio-economic variables\\\",\n dep.var.labels =3D c(\\\"Per = capita calorie intake\\\",\\\"Log of per capita calorie intake\\\"),\n = se=3Dlist(NULL,robust_se,robust_se2),\n = omit=3D\\\"state\\\",\n model.numbers=3DFALSE,\n = report =3D \\\"vct*\\\",\n single.row=3DTRUE,\n = omit.labels =3D \\\"State and region dummies\\\")\", visibly =3D FALSE, = output =3D TRUE, file =3D = '/var/folders/hj/hqfjch716qg5php160jbtfgh0000gn/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=3Dregdata,weights=3Dweight)->reg\nlm(adj_cal~sector+sex+AgeChild+AgeA= dult+foodprice+log(MPCE)+state_region,data=3Dregdata,weights=3Dweight)->re= g.1\nlibrary(car)\nlibrary(lmtest)\nlibrary(sandwich)\ncov1 <- = vcovHC(reg, type =3D \"HC1\")\nrobust_se <- sqrt(diag(cov1))\n\ncov2 = <- vcovHC(reg.1, type =3D \"HC1\")\nrobust_se2 <- = sqrt(diag(cov2))\n # Adjust F = statistic\nwald_results <- waldtest(reg, vcov =3D cov1)\nwald_results2 = <- waldtest(reg.1, vcov =3D cov2)\n\n = #coeftest(reg, vcov =3D hccm)->reg2\noptions(scipen =3D = 999)\nlibrary(stargazer)\nstargazer(reg.1,reg,\n align=3DTRUE,\n = title=3D\"Regression of per capita calorie intake with monthly = per capita consumer expenditure, and demographic and other = socio-economic variables\",\n dep.var.labels =3D c(\"Per capita = calorie intake\",\"Log of per capita calorie intake\"),\n = se=3Dlist(NULL,robust_se,robust_se2),\n omit=3D\"state\",\n = model.numbers=3DFALSE,\n report =3D \"vct*\",\n = single.row=3DTRUE,\n omit.labels =3D \"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=3Dregdata,weights=3Dweight)->reg\nlm(adj_cal~sector+sex+AgeChild+AgeA= dult+foodprice+log(MPCE)+state_region,data=3Dregdata,weights=3Dweight)->re= g.1\nlibrary(car)\nlibrary(lmtest)\nlibrary(sandwich)\ncov1 <- = vcovHC(reg, type =3D \"HC1\")\nrobust_se <- sqrt(diag(cov1))\n\ncov2 = <- vcovHC(reg.1, type =3D \"HC1\")\nrobust_se2 <- = sqrt(diag(cov2))\n # Adjust F = statistic\nwald_results <- waldtest(reg, vcov =3D cov1)\nwald_results2 = <- waldtest(reg.1, vcov =3D cov2)\n\n = #coeftest(reg, vcov =3D hccm)->reg2\noptions(scipen =3D = 999)\nlibrary(stargazer)\nstargazer(reg.1,reg,\n align=3DTRUE,\n = title=3D\"Regression of per capita calorie intake with monthly = per capita consumer expenditure, and demographic and other = socio-economic variables\",\n dep.var.labels =3D c(\"Per capita = calorie intake\",\"Log of per capita calorie intake\"),\n = se=3Dlist(NULL,robust_se,robust_se2),\n omit=3D\"state\",\n = model.numbers=3DFALSE,\n report =3D \"vct*\",\n = single.row=3DTRUE,\n omit.labels =3D \"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=3Dregdata,weights=3Dweight)->reg\nlm(adj_cal~sect= or+sex+AgeChild+AgeAdult+foodprice+log(MPCE)+state_region,data=3Dregdata,w= eights=3Dweight)->reg.1\nlibrary(car)\nlibrary(lmtest)\nlibrary(sandwich)\= ncov1 <- vcovHC(reg, type =3D \"HC1\")\nrobust_se <- = sqrt(diag(cov1))\n\ncov2 <- vcovHC(reg.1, type =3D = \"HC1\")\nrobust_se2 <- sqrt(diag(cov2))\n = # Adjust F statistic\nwald_results <- waldtest(reg, vcov =3D = cov1)\nwald_results2 <- waldtest(reg.1, vcov =3D cov2)\n\n = #coeftest(reg, vcov =3D = hccm)->reg2\noptions(scipen =3D = 999)\nlibrary(stargazer)\nstargazer(reg.1,reg,\n align=3DTRUE,\n = title=3D\"Regression of per capita calorie intake with monthly = per capita consumer expenditure, and demographic and other = socio-economic variables\",\n dep.var.labels =3D c(\"Per capita = calorie intake\",\"Log of per capita calorie intake\"),\n = se=3Dlist(NULL,robust_se,robust_se2),\n omit=3D\"state\",\n = model.numbers=3DFALSE,\n report =3D \"vct*\",\n = single.row=3DTRUE,\n omit.labels =3D \"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 wrote: >=20 > On Sun, 29 May 2016, Vikas Rawal wrote: >=20 >>=20 >>>=20 >>> Vikas, can you edit the `sit-for' to `sleep-for' in >>>=20 >>> `org-babel-comint-eval-invisibly-and-wait-for-file' >>>=20 >>> and `eval-defun' the result and see if that has any effect? >>>=20 >>=20 >=20 >> Sorry, given my limited ability with lisp, I do not really >> understand. Could you please spell out what do I have to do. >=20 > Vikas, >=20 > Copy the src-block at bottom to a *.org file or org-mode buffer. Then > execute it with `C-c C-c y'. >=20 > You should see >=20 > #+RESULTS: > : org-babel-comint-eval-invisibly-and-wait-for-file >=20 > appear afterwards. >=20 > Then try running your R code to see if it works reliably. >=20 > Does that seem to fix it? >=20 > If not, please check the session buffer to see if there were any > warnings or errors. >=20 > Chuck >=20 >=20 > #+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 (=3D (aref string (1- (length string))) ?\n) string = (concat string "\n"))) > ;; =46rom 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)))) >=20 > #+END_SRC