Difference between auto generated .nb.html and Knit to HTML?

I'm new to R Markdown. I'm using R Notebook, which automatically creates the xx.nb.html. But when I start to adjust some configuration, e.g. in the top yaml block, they don't seem to work. There is no TOC, the "code_folding: hide" to by default Hide All Code, does not work (I do want the option to open and see the code block), and the theme also doesn't seem to work (though I haven't checked what to expect). In the CSS that I supplied, it seems to take my headings styles, but not others like removing the double borders for the code blocks, title style.

    css: /.../.../my.css
    toc: true
    theme: united
    df_print: paged
    code_folding: hide

I wonder if it's because I need to knit the html. But when I "Knit to HTML", I got the following error message: "Error: RStudio not running":

What am I doing wrong? I'm using R Studio 1.1.423 and it works well.


You have two different questions in this post.

Your main question (about the difference) is that files with "nb" in the name is a notebook. It reflects the same things that you have run interactively. So, for example, when you click on the "Play" arrow for a chunk, output of this chunk will be in this file. However, to get all the things you've mentioned (css, TOC, etc.) you need to knit the document.

Basically, "nb" file is a preview. Once you knit, all of the chunks will start from new R session, so the document you get at the end (without "nb" in the name) is reproducible.

As for the error you are seeing ("RStudio not running") -- I have no idea what that means, unfortunately.

Thanks @mishabalyasin. So I do need to get the Knit to HTML to work. Somewhere I read for the same error message was because that person is using rstudioapi, and they are not in the same R session and hence the error message. But I'm not using api. I'm clicking on the Knit to HTML in the R Studio directly. Wonder why the error message.

Does it fail on all notebooks? Can you isolate to a small example that deterministically fails?

Good question @mishabalyasin. All my recent files have the same problem, but I recall an old file I got from someone who has knitted it to html. I tried to knit that .rmd and it was successful. With this result and your information on that the knit will start from a new R session, I'm pretty sure the reason is because at the beginning of the code, it requires an interactive login, which won't work in a new R session without me interactively entering things. Thanks for helping the troubleshoot. I'll have to figure out a way to do without interactive session.

And I confirmed that it works now after I remove the interactive input part. Thanks again!