0

This is the code:

# State with most Zip code
    x <- df3 %>% count(state) %>% 
           arrange(desc(n)) 

     x[1,]

it returns

state   n
Texas   1935

My markdown is:

The state which has the most zip code is x[1,1] with a total of x[1,2] zip codes.

but what I would like is the markdown to say:

The state which has the most zip code is Texas with a total of 1935 zip codes automatically based on my output x.

I tried all sort of combination of tick marks and {{...}} but to no avails...

Konrad Rudolph
  • 530,221
  • 131
  • 937
  • 1,214
melimelo
  • 1
  • 2
  • Last I knew this is a place where R markdown use inside RStudio, see [here](https://rmarkdown.rstudio.com/articles_intro.html), is better suited for what you describe. [This discussion](https://discourse.jupyter.org/t/inline-variable-insertion-in-markdown/10525?u=fomightez) will probably be of interest to you. However, most of it focuses on the ipykernel-based notebooks and not the irkernel-based notebooks. Likewise, in ipykernel-based notebooks you can use [this code](https://stackoverflow.com/a/32035217/8508004) to have Python code that makes markdown in output cells. I don't know the R ... – Wayne Nov 27 '22 at 21:22
  • equivalent, sadly. I refer to that code and the Python Markdown extension [here](https://discourse.jupyter.org/t/how-to-add-markdown-inside-a-function-to-pretty-print-equation/2719/2?u=fomightez). I don't know of the irkernel equivalent of that extension though. UPDATE: [here](https://stackoverflow.com/q/35786496/8508004) references code that "This perfectly does the job of printing Markdown inside a code cell." So that may be a lead. (I think it means [here](https://stackoverflow.com/a/32717083/8508004)?) – Wayne Nov 27 '22 at 21:23

0 Answers0