Quarto: Locals, globals, dynamic text #11
Replies: 12 comments 11 replies
-
I think this may again be more of a Quarto question. (I'm guessing that you are doing something like this but with
If you are using an external system (other than Jupyter Lab) like Quarto that plugs in to one of these interfaces (in Quarto's case, the kernel), your questions/doc searches are most likely better directed there. |
Beta Was this translation helpful? Give feedback.
-
Thank you for the information
Best wishes
…On Mon, Mar 6, 2023 at 12:38 PM Tim Huegerich ***@***.***> wrote:
I think may again be more of a Quarto question. nbstata basically
provides two well-defined interfaces:
1. A Stata Jupyter kernel
<https://docs.jupyter.org/en/latest/projects/kernels.html#kernels>
2. A Python API to assist using Stata from within Python code
(currently, this is documented only in the Developer Docs
<https://hugetim.github.io/nbstata/dev_docs_index.html>)
If you are using an external system (other than Jupyter Lab) like Quarto
that plugs in to one of these interfaces (in Quarto's case, the kernel),
your questions/doc searches are most likely better directed there.
—
Reply to this email directly, view it on GitHub
<#9 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/ASZKKFWOLLB5XITJGAOL2ITW2YOKFANCNFSM6AAAAAAVRMWATI>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
Beta Was this translation helpful? Give feedback.
-
I'm really interested in learning more from your experience of using nbstata with Quarto (or other platforms), though. Anything you are willing to share would be most welcome. |
Beta Was this translation helpful? Give feedback.
-
Certainly!
I recently started working using Quarto. So I'm mostly doing some work with
Stata. NOw I'm trying to integrate the examples with Stata code and Output.
This will save me time, as opposed to running all examples outside quarto,
and just copy-pasting the outcomes.
Im also planning to write a "summary statistics paper". I can certainly
share that with you when that is done.
For now, in regards to my Local question, i decided to do it internally,
using something like this:
```{stata}
*| output: asis
*| echo : false
qui:sysuse auto, clear
qui:regress price mpg
display "Based on the model, when a car is more fuel efficient, the cost
decreases in " %5.1f `=_b[mpg]' " dollars."
```
This should work since only few of the dynamic parameters in the paper
require explicit explanation.
Thank you
Fernando
…On Mon, Mar 6, 2023 at 1:08 PM Tim Huegerich ***@***.***> wrote:
I'm really interested in learning more from your experience of using
nbstata with Quarto (or other platforms), though. Anything you are willing
to share would be most welcome here: #10
<https://github.com/hugetim/nbstata/discussions/10>
—
Reply to this email directly, view it on GitHub
<#9 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/ASZKKFWB6JJJQDB7EIXYCZLW2YRYBANCNFSM6AAAAAAVRMWATI>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
Beta Was this translation helpful? Give feedback.
-
A colleague pointed me to a thread on Statalist that led me here. I'm getting great results using nbstata to write Stata Jupyter Notebooks in JupyterLab and then rendering them using Quarto. Article example: https://sscc.wisc.edu/sscc/pubs/stata_dates/ Setting up the site formatting in Quarto took some figuring out, but not too bad. I'm still figuring out best ways to use it. I switched to nbstata because it has the echo behavior I want. I did have some trouble with JuptyerLab on my laptop after installing nbstata and Stata syntax highlighting, but since they just work on our Linux servers I haven't investigated. (I can start JupyterLab on a Linux server and point a local browser to it, so it's just like running it on my laptop anyway.) Thank you Tim! Russell Dimond |
Beta Was this translation helpful? Give feedback.
-
I saw that.
Because Stata uses * for comments, you also have to use * to provide
directives in Quarto
for example:
```{stata}
*| echo: false
*| output: asis
qui:reg price mpg foreign
est sto m1
esttab m1, md nonum
```
This is what I used to create the toy example I posted on Statalist
…On Fri, Mar 10, 2023 at 5:49 PM Tim Huegerich ***@***.***> wrote:
That would make sense. The syntax highlighting extension was much more
finicky to get working for me (as I know so little JavaScript).
When starting from a Jupyter Notebook with nbstata, is it an issue that
the Quarto directives (starting with #|) aren't valid Stata comments?
Would it be helpful if I made nbstata ignore those lines?
—
Reply to this email directly, view it on GitHub
<#11 (reply in thread)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ASZKKFUE3XJGUCVEDPJXEY3W3OVYLANCNFSM6AAAAAAVW67KMM>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
Beta Was this translation helpful? Give feedback.
-
Quarto is blowing my mind. It seemed impenetrable as I browsed randomly through the reference docs to find answers to particular questions. But then I finally broke down and...worked through the tutorials. 🌩💡 Working through the tutorials will be a bigger challenge for Stata users without experience in any of the tutorial reference languages, so I'd like to add a Stata Quarto tutorial to the docs here soon. |
Beta Was this translation helpful? Give feedback.
-
That is an excellent idea!
…On Fri, Mar 10, 2023 at 8:41 PM Tim Huegerich ***@***.***> wrote:
Quarto is blowing my mind. It seemed impenetrable as I browsed randomly
through the reference docs to find answers to particular questions. But
then I finally broke down and...worked through the tutorials. 🌩💡
Working through the tutorials will be a bigger challenge for Stata users
without experience in any of the tutorial reference languages, so I'd like
to add a Stata Quarto tutorial to the docs here soon.
—
Reply to this email directly, view it on GitHub
<#11 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ASZKKFVCD26BT2C2VW74G3TW3PJ2XANCNFSM6AAAAAAVW67KMM>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
Beta Was this translation helpful? Give feedback.
-
Are you thinking just using the same design but with Stata as the main
language?
On Fri, Mar 10, 2023 at 9:01 PM Fernando Rios-Avila ***@***.***>
wrote:
… That is an excellent idea!
On Fri, Mar 10, 2023 at 8:41 PM Tim Huegerich ***@***.***>
wrote:
> Quarto is blowing my mind. It seemed impenetrable as I browsed randomly
> through the reference docs to find answers to particular questions. But
> then I finally broke down and...worked through the tutorials. 🌩💡
>
> Working through the tutorials will be a bigger challenge for Stata users
> without experience in any of the tutorial reference languages, so I'd like
> to add a Stata Quarto tutorial to the docs here soon.
>
> —
> Reply to this email directly, view it on GitHub
> <#11 (comment)>,
> or unsubscribe
> <https://github.com/notifications/unsubscribe-auth/ASZKKFVCD26BT2C2VW74G3TW3PJ2XANCNFSM6AAAAAAVW67KMM>
> .
> You are receiving this because you were mentioned.Message ID:
> ***@***.***>
>
|
Beta Was this translation helpful? Give feedback.
-
Started to look into it
It will definitely need some tweaking for rare cases
but, for the examples they provide (computation), perhaps the following
will be enough
```{stata}
mata:a = rowshape(1::15, 5)
mata:a
```
```{stata}
*| label: fig-limits
*| fig-cap: "Citations vs Fines"
qui:webuse dui, clear
two scatter citations fines || lpolyci citations fines, xsize(10) ysize(5)
```
```{stata}
*| label: fig-gapminder
*| fig-cap: Life Expectancy and GDP
*| fig-subcap:
*| - "Gapminder: 1957"
*| - "Gapminder: 2007"
*| layout-ncol: 2
*| column: page
*| echo: false
qui:sysuse auto, clear
scatter price mpg if foreign==1, name(m1, replace)
scatter price mpg if foreign==0, name(m2, replace)
```
NOTE: Mata output is odd. Because every one comes up in the screen. Kind of
how it is when "doing" a dofile
But not sure what is the better approach
For figures, The sizes and resolutions seem to be better defined using
xsize and ysize
and for multiple figures, it seems necessary to "save" graphs in memory in
order to use the layout for multiple figures.
F
…On Fri, Mar 10, 2023 at 9:15 PM Tim Huegerich ***@***.***> wrote:
Yes, that was what I was thinking. We could either copy and adapt the qmd
source of the web pages...or the less ambitious option would be to just
create sample notebooks and .qmd files that folks could reference and play
with as they work through the Python or R tutorial.
—
Reply to this email directly, view it on GitHub
<#11 (reply in thread)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ASZKKFXIN33NJQJVO3LF5MTW3PN4BANCNFSM6AAAAAAVW67KMM>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
Beta Was this translation helpful? Give feedback.
-
Thanks for catching that—it’s been corrected and a link added.
Russell
From: Tim Huegerich ***@***.***>
Sent: Monday, September 11, 2023 2:51 PM
To: hugetim/nbstata ***@***.***>
Cc: Russell Dimond ***@***.***>; Mention ***@***.***>
Subject: Re: [hugetim/nbstata] Quarto: Locals, globals, dynamic text (Discussion #11)
@rdimond<https://github.com/rdimond> I don't know how much trouble it would be for you to do this after the fact, but it might help Googlers find nbstata if you were able to correct the spelling of "nbstata" in the Stata dates<https://sscc.wisc.edu/sscc/pubs/stata_dates/> article (from "nbstat kernel"). And even better would be to link to https://hugetim.github.io/nbstata/ from that page.
(I just happened to notice this as I was sending that page to someone as an example of using nbstata with Quarto.)
—
Reply to this email directly, view it on GitHub<#11 (reply in thread)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/ABA3KCBKQDJMYWT4PFYV5P3XZ5TTTANCNFSM6AAAAAAVW67KMM>.
You are receiving this because you were mentioned.Message ID: ***@***.******@***.***>>
|
Beta Was this translation helpful? Give feedback.
-
New Statalist Quarto thread: https://www.statalist.org/forums/forum/general-stata-discussion/general/1765340-literate-programming-and-cross-reference-of-formatted-tables |
Beta Was this translation helpful? Give feedback.
-
I tried to look into the documentation but couldn't find information about the following.
Is it possible to do inline coding?
for example something like this inline.
So that if I type
stata e(r2)
(or similar) to display the desired outcome? (Print R2 of a regression, in line)Thank you
Beta Was this translation helpful? Give feedback.
All reactions