Closed muschellij2 closed 1 year ago
Also added some additional paths for Mac OSX Stata.
John, thanks! It will be a couple of days before I have a chance to review this, just so you know. Not sure I understand the original problem – could you provide me a little example so I too can reproduce the problem? Have you used this with Stata 16 yet?
From: John Muschelli notifications@github.com Sent: Thursday, July 18, 2019 5:40 PM To: Hemken/Statamarkdown Statamarkdown@noreply.github.com Cc: Subscribed subscribed@noreply.github.com Subject: [Hemken/Statamarkdown] Fixed for me (#4)
I was using roctab x y with 2 variables in a data set and couldn't knit anything. I think this was because my log was much more than 1 line (even for a simple command roctab). I was getting empty verbatim otherwise.
You can view, comment on, or merge this pull request online at:
https://github.com/Hemken/Statamarkdown/pull/4
Commit Summary
File Changes
Patch Links:
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHubhttps://github.com/Hemken/Statamarkdown/pull/4?email_source=notifications&email_token=ACYBMEZ2E434ADJ3GWJCFRLQADWNJA5CNFSM4IFAIPV2YY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4HAEAEWA, or mute the threadhttps://github.com/notifications/unsubscribe-auth/ACYBME3TCCAETSFESWQDOCLQADWNJANCNFSM4IFAIPVQ.
John, I can’t reproduce the problem? When I set up a roctab
command using the Stata reference example, I get output just fine, both under Windows and under linux. Can you send me the example RMD that caused you problems?
From: John Muschelli notifications@github.com Sent: Thursday, July 18, 2019 5:40 PM To: Hemken/Statamarkdown Statamarkdown@noreply.github.com Cc: Subscribed subscribed@noreply.github.com Subject: [Hemken/Statamarkdown] Fixed for me (#4)
I was using roctab x y with 2 variables in a data set and couldn't knit anything. I think this was because my log was much more than 1 line (even for a simple command roctab). I was getting empty verbatim otherwise.
You can view, comment on, or merge this pull request online at:
https://github.com/Hemken/Statamarkdown/pull/4
Commit Summary
File Changes
Patch Links:
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHubhttps://github.com/Hemken/Statamarkdown/pull/4?email_source=notifications&email_token=ACYBMEZ2E434ADJ3GWJCFRLQADWNJA5CNFSM4IFAIPV2YY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4HAEAEWA, or mute the threadhttps://github.com/notifications/unsubscribe-auth/ACYBME3TCCAETSFESWQDOCLQADWNJANCNFSM4IFAIPVQ.
I can't reproduce the issue I was having in a larger document, but here are some things to show when there is a profile.do
file:
library(haven)
library(devtools)
#> Loading required package: usethis
library(rmarkdown)
dataset = "sample_data.dta"
x = c(rep(0, 52), rep(1, 32),
rep(0, 35), rep(1, 50))
y = c(rep(0, 84), rep(1, 85))
df = data.frame(x,y)
haven::write_dta(data = df, path = dataset, version = 13)
dataset = normalizePath(dataset)
doc = c("---", "output: github_document", "---", "", "```{r pressure, echo=FALSE}",
"library(Statamarkdown)", "knitr::opts_chunk$set(", " collapse = TRUE,",
" cache = TRUE,", " message = FALSE,", " warning = FALSE,",
" prompt = FALSE,", " comment = \"\")", "knitr::opts_chunk$set(fig.pos = \"H\")",
"statapath = \"/Applications/Stata/Stata.app/Contents/MacOS/Stata\"",
"```", "", "", "```{stata, engine.path = statapath}",
# paste0("use ", dataset, ", clear"),
"roctab x y", "```", "")
rmd = tempfile(fileext = ".Rmd")
writeLines(doc, rmd)
profile_do = file.path(dirname(rmd), "profile.do")
x = paste0('use "', dataset, '"')
writeLines(x, profile_do)
devtools::install_github("Hemken/Statamarkdown")
#> Downloading GitHub repo Hemken/Statamarkdown@master
#>
#>
checking for file ‘/private/var/folders/1s/wrtqcpxn685_zk570bnx9_rr0000gr/T/RtmpnsoqtE/remotes82a4b452103/Hemken-Statamarkdown-b14bd12/DESCRIPTION’ ...
✔ checking for file ‘/private/var/folders/1s/wrtqcpxn685_zk570bnx9_rr0000gr/T/RtmpnsoqtE/remotes82a4b452103/Hemken-Statamarkdown-b14bd12/DESCRIPTION’
#>
─ preparing ‘Statamarkdown’:
#>
checking DESCRIPTION meta-information ...
✔ checking DESCRIPTION meta-information
#>
─ checking for LF line-endings in source and make files and shell scripts
#>
─ checking for empty or unneeded directories
#>
─ building ‘Statamarkdown_0.3.8.tar.gz’
#>
#>
#> Adding 'Statamarkdown_0.3.8.tgz' to the cache
rmarkdown::render(rmd)
#> processing file: file82a6335e875.Rmd
#> running: /Applications/Stata/Stata.app/Contents/MacOS/Stata -q -e do '/private/var/folders/1s/wrtqcpxn685_zk570bnx9_rr0000gr/T/RtmpnsoqtE/stata82a55caaddb.do'
#> stata output from unnamed-chunk-1
#> character(0)
#> output file: file82a6335e875.knit.md
#> /usr/local/bin/pandoc +RTS -K512m -RTS file82a6335e875.utf8.md --to gfm-ascii_identifiers --from markdown+autolink_bare_uris+tex_math_single_backslash --output file82a6335e875.md --standalone --template /Library/Frameworks/R.framework/Versions/3.6/Resources/library/rmarkdown/rmarkdown/templates/github_document/resources/default.md
#> /usr/local/bin/pandoc +RTS -K512m -RTS file82a6335e875.md --to html4 --from gfm-ascii_identifiers --output file82a6335e875.html --standalone --self-contained --highlight-style pygments --template /Library/Frameworks/R.framework/Versions/3.6/Resources/library/rmarkdown/rmarkdown/templates/github_document/resources/preview.html --variable 'github-markdown-css:/Library/Frameworks/R.framework/Versions/3.6/Resources/library/rmarkdown/rmarkdown/templates/github_document/resources/github.css' --email-obfuscation none --metadata pagetitle=PREVIEW
#>
#> Preview created: file82a6335e875.html
#>
#> Output created: file82a6335e875.md
readLines(sub(".Rmd", ".md", rmd))
#> [1] ""
#> [2] " #> Stata found at /Applications/Stata//Stata.app"
#> [3] " #> Found an existing 'profile.do'"
#> [4] " #> use \"/private/var/folders/1s/wrtqcpxn685_zk570bnx9_rr0000gr/T/Rtmp9kIgCG/reprex39527ad87b7/sample_data.dta\""
#> [5] " #> The 'stata' engine is ready to use."
#> [6] ""
#> [7] "``` stata"
#> [8] "roctab x y"
#> [9] " ROC -Asymptotic Normal--"
#> [10] " Obs Area Std. Err. [95% Conf. Interval]"
#> [11] " --------------------------------------------------------"
#> [12] " 169 0.6037 0.0379 0.52952 0.67793"
#> [13] "```"
remove.packages("Statamarkdown")
#> Removing package from '/Library/Frameworks/R.framework/Versions/3.6/Resources/library'
#> (as 'lib' is unspecified)
devtools::install_github("muschellij2/Statamarkdown")
#> Downloading GitHub repo muschellij2/Statamarkdown@master
#>
#>
checking for file ‘/private/var/folders/1s/wrtqcpxn685_zk570bnx9_rr0000gr/T/RtmpnsoqtE/remotes82adfca0a6/muschellij2-Statamarkdown-736fefd/DESCRIPTION’ ...
✔ checking for file ‘/private/var/folders/1s/wrtqcpxn685_zk570bnx9_rr0000gr/T/RtmpnsoqtE/remotes82adfca0a6/muschellij2-Statamarkdown-736fefd/DESCRIPTION’
#>
─ preparing ‘Statamarkdown’:
#>
checking DESCRIPTION meta-information ...
✔ checking DESCRIPTION meta-information
#>
─ checking for LF line-endings in source and make files and shell scripts
#>
─ checking for empty or unneeded directories
#>
─ building ‘Statamarkdown_0.3.8.tar.gz’
#>
#>
#> Adding 'Statamarkdown_0.3.8.tgz' to the cache
rmarkdown::render(rmd)
#> processing file: file82a6335e875.Rmd
#> running: /Applications/Stata/Stata.app/Contents/MacOS/Stata -q -e do '/private/var/folders/1s/wrtqcpxn685_zk570bnx9_rr0000gr/T/RtmpnsoqtE/stata82a6db762c7.do'
#> output file: file82a6335e875.knit.md
#> /usr/local/bin/pandoc +RTS -K512m -RTS file82a6335e875.utf8.md --to gfm-ascii_identifiers --from markdown+autolink_bare_uris+tex_math_single_backslash --output file82a6335e875.md --standalone --template /Library/Frameworks/R.framework/Versions/3.6/Resources/library/rmarkdown/rmarkdown/templates/github_document/resources/default.md
#> /usr/local/bin/pandoc +RTS -K512m -RTS file82a6335e875.md --to html4 --from gfm-ascii_identifiers --output file82a6335e875.html --standalone --self-contained --highlight-style pygments --template /Library/Frameworks/R.framework/Versions/3.6/Resources/library/rmarkdown/rmarkdown/templates/github_document/resources/preview.html --variable 'github-markdown-css:/Library/Frameworks/R.framework/Versions/3.6/Resources/library/rmarkdown/rmarkdown/templates/github_document/resources/github.css' --email-obfuscation none --metadata pagetitle=PREVIEW
#>
#> Preview created: file82a6335e875.html
#>
#> Output created: file82a6335e875.md
readLines(sub(".Rmd", ".md", rmd))
#> [1] ""
#> [2] "``` stata"
#> [3] "roctab x y"
#> [4] " . roctab x y"
#> [5] ""
#> [6] " ROC -Asymptotic Normal--"
#> [7] " Obs Area Std. Err. [95% Conf. Interval]"
#> [8] " --------------------------------------------------------"
#> [9] " 169 0.6037 0.0379 0.52952 0.67793"
#> [10] "```"
unlink(dataset)
unlink(profile_do)
Created on 2019-07-29 by the reprex package (v0.3.0)
John, thanks.
Looking at your example, I’d say your version and my (new) version produce the same output.
You should be aware that the preferred way to specify language engine paths has changed as of knitr 1.21 or so. See https://yihui.name/knitr/options/#language-engines . So now you would code
knitr::opts_chunk$set(engine.path=list(stata=statapath)
and you could begin each chunk with just
In my version of the package I’ve incorporated your MacOS update, so you shouldn’t need to specify the Stata path or set the chunk option – it should now be automated. So your doc could now be written as:
doc = c("---",
"output: github_document",
"---",
"",
"{r pressure, echo=FALSE}", "library(Statamarkdown)", "knitr::opts_chunk$set(", " collapse = TRUE,", " cache = TRUE,", " message = FALSE,", " warning = FALSE,", " prompt = FALSE,", " comment = \"\")", "knitr::opts_chunk$set(fig.pos = \"H\")", "
",
"",
"",
"```{stata}",
"roctab x y",
"```",
"")
From: John Muschelli notifications@github.com Sent: Monday, July 29, 2019 2:01 PM To: Hemken/Statamarkdown Statamarkdown@noreply.github.com Cc: Doug Hemken dehemken@wisc.edu; Comment comment@noreply.github.com Subject: Re: [Hemken/Statamarkdown] Fixed for me (#4)
I can't reproduce the issue I was having in a larger document, but here are some things to show when there is a profile.do file:
library(haven)
library(devtools)
library(rmarkdown)
dataset = "sample_data.dta"
x = c(rep(0, 52), rep(1, 32),
rep(0, 35), rep(1, 50))
y = c(rep(0, 84), rep(1, 85))
df = data.frame(x,y)
haven::write_dta(data = df, path = dataset, version = 13)
dataset = normalizePath(dataset)
doc = c("---", "output: github_document", "---", "", "```{r pressure, echo=FALSE}",
"library(Statamarkdown)", "knitr::opts_chunk$set(", " collapse = TRUE,",
" cache = TRUE,", " message = FALSE,", " warning = FALSE,",
" prompt = FALSE,", " comment = \"\")", "knitr::opts_chunk$set(fig.pos = \"H\")",
"statapath = \"/Applications/Stata/Stata.app/Contents/MacOS/Stata\"",
"```", "", "", "```{stata, engine.path = statapath}",
# paste0("use ", dataset, ", clear"),
"roctab x y", "```", "")
rmd = tempfile(fileext = ".Rmd")
writeLines(doc, rmd)
profile_do = file.path(dirname(rmd), "profile.do")
x = paste0('use "', dataset, '"')
writeLines(x, profile_do)
devtools::install_github("Hemken/Statamarkdown")
checking for file ‘/private/var/folders/1s/wrtqcpxn685_zk570bnx9_rr0000gr/T/RtmpnsoqtE/remotes82a4b452103/Hemken-Statamarkdown-b14bd12/DESCRIPTION’ ...
✔ checking for file ‘/private/var/folders/1s/wrtqcpxn685_zk570bnx9_rr0000gr/T/RtmpnsoqtE/remotes82a4b452103/Hemken-Statamarkdown-b14bd12/DESCRIPTION’
─ preparing ‘Statamarkdown’:
checking DESCRIPTION meta-information ...
✔ checking DESCRIPTION meta-information
─ checking for LF line-endings in source and make files and shell scripts
─ checking for empty or unneeded directories
─ building ‘Statamarkdown_0.3.8.tar.gz’
rmarkdown::render(rmd)
readLines(sub(".Rmd", ".md", rmd))
remove.packages("Statamarkdown")
devtools::install_github("muschellij2/Statamarkdown")
checking for file ‘/private/var/folders/1s/wrtqcpxn685_zk570bnx9_rr0000gr/T/RtmpnsoqtE/remotes82adfca0a6/muschellij2-Statamarkdown-736fefd/DESCRIPTION’ ...
✔ checking for file ‘/private/var/folders/1s/wrtqcpxn685_zk570bnx9_rr0000gr/T/RtmpnsoqtE/remotes82adfca0a6/muschellij2-Statamarkdown-736fefd/DESCRIPTION’
─ preparing ‘Statamarkdown’:
checking DESCRIPTION meta-information ...
✔ checking DESCRIPTION meta-information
─ checking for LF line-endings in source and make files and shell scripts
─ checking for empty or unneeded directories
─ building ‘Statamarkdown_0.3.8.tar.gz’
rmarkdown::render(rmd)
readLines(sub(".Rmd", ".md", rmd))
unlink(dataset)
unlink(profile_do)
Created on 2019-07-29 by the reprex packagehttps://reprex.tidyverse.org (v0.3.0)
— You are receiving this because you commented. Reply to this email directly, view it on GitHubhttps://github.com/Hemken/Statamarkdown/pull/4?email_source=notifications&email_token=ACYBME4LW3DHZGFRLM6NSE3QB445RA5CNFSM4IFAIPV2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD3BV4ZY#issuecomment-516120167, or mute the threadhttps://github.com/notifications/unsubscribe-auth/ACYBMEY2ZH2BA5CSHM6344TQB445RANCNFSM4IFAIPVQ.
I was using
roctab x y
with 2 variables in a data set and couldn't knit anything. I think this was because my log was much more than 1 line (even for a simple commandroctab
). I was getting empty verbatim otherwise.