Git Product home page Git Product logo

Comments (5)

avila avatar avila commented on May 28, 2024 1

Thank you for the quick reply. Although that is not the exact issue, it did point me in the right direction. I am not very familiar with quarto but it does seem that in interactive mode, knitr is doing the job of executing the cells. I'll try to illustrate the issue here, as it might be helpful to others (or at least me in the future!)

It seems that knitr creates a temporary sh file with the following content and tries to call that from the default shell.

{engine} /tmp/tempfilename.txt

So it enters Stata in normal (not batch mode) and it never returns any output or error until I cancel the call via the stop button, when I can then see Stata's splash and the error (/ is not a valid command). See, for example, if I rename the engine to something random:

image

Having said that, there is indeed a knitr engine called stata. So I don't know why that is not being called. I did set jupyter (and nbstata as the kernel) when creating the document (see next screenshot).

image

Having said all that, it is very likely that the issue is either with quarto or with knitr. I'll try to figure it out, and I'll link back to this issue any relevant info I find.


By the way (not relevant to this issue) I also opened an issue in quarto's repository asking about support for nbstata. Is there any documentation on using nbstata with quarto (from VSCode or any other editor?).

from nbstata.

avila avatar avila commented on May 28, 2024 1

One possible workaround would be setting a custom knitr engine and trying to make sure it points to python (jupyter) and uses nbstata. (here for context: https://bookdown.org/yihui/rmarkdown-cookbook/custom-engine.html)

Disclaimer: that I have a very shallow understanding of how knitr and jupyter kernels work.

And here is a minumum reproducible example of a document.

---
title: "nbstata"
format: html
jupyter: nbstata
---

## nbstata 

```{stata}
di 1 + 1 
```

Note that the document does not include the usual knitr setup chunk that a Rmarkdown usually includes.

from nbstata.

avila avatar avila commented on May 28, 2024 1

That's great that quarto is now supporting nbstata! I just did a quick test with simple documents, and it ran fine on VSCode (interactive execution and compilation).

On RStudio the conflict between the default stata engine (from knitr) and nbstata via jupyter is still present. However! I found out a few weeks ago that due to Fedora's packaging guidelines, quarto is not bundled-up with RStudio as distributed by Fedora (see: rstudio/rstudio#12609). So I am not sure if the conflict is only in Fedora distributions or a more generic issue.

In any case, a quarto document with nbstata kernel can be compiled with quarto::quarto_render("file.qmd") from R or with quarto render file.qmd from the terminal. The source file can be edited from RStudio but (at least in my system) interactive code execution does not work. If I get the chance to play with another distribution, I'll make sure to test it and report back.

from nbstata.

hugetim avatar hugetim commented on May 28, 2024

Thank you for reporting. I think that when you run stata interactively in RStudio, it's not actually using nbstata.[1] I bet you're using the knitr version of Stata instead (about which I only have a vague awareness). Maybe Stata 18 broke something about how knitr stata worked? I think you should instead report this to the knitr project (but do report back if you would).[2]

By contrast, according to my hypothesis, when you render using Quarto, it is using nbstata and working.

[1] One clue is that the Stata "splash," that several-line display of the Stata version and so on, is disabled by default in nbstata. It's also hard for me to imagine how nbstata could trigger an error like that.
[2] An additional piece of info that may be helpful to them is the Stata revision date.

from nbstata.

hugetim avatar hugetim commented on May 28, 2024

Thank you, @avila, for that quarto issue which led to nbstata support in the Quarto VSCode extension.

I'd like to add further documentation directing people toward that extension (and also how to use nbstata with RStudio if there is a way), but I won't have time to work on it myself until July at the earliest.

from nbstata.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.