Add distinction between comments and headers to the end of chapter 7. Call it 7.7 Things to keep in mind when using R Markdown files. Or something like that. Refer back to 4.6.
2020-06-03 a student asked this question at the bottom of the lab:
"I’m still a bit confused on the difference between the this text and the #comment from the line above. I understand that the explanatory text can be formatted etc. in markdown, but is there any reason to use #comments in these files (or just in R scripts?) **After exporting to html, I now am assuming that the ## are headers"
Here was my answer, which I can probably use in the book:
Comments (as a concept) can be written in markdown documents or in R scripts. As you correctly pointed out, the syntax for writing comments (how to write them) differs depending on where you write them.
In R scripts: R scripts only allow comments that begin with #. Additionally, comments in R scripts can't really be formatted or styled.
In R Markdown files (including Notebooks): Comments can be written plain text anywhere in the Notebook file except inside a code chunk. Inside a code chunk, comments must still begin with #. Remember, code chunks are kind of like little individual R scripts.
In R Markdown files (including Notebooks): Comments can be formatted and styled using markdown syntax. In markdown syntax # represents a level-1 header, ## represents a level-2 header, ### represents a level-3 header and #### represents a level-4 header.
In R Markdown files (including Notebooks): When would you choose to write comments around code chunks with markdown vs. writing comments inside code chunks with #? This is a good question and I'm not aware of any specific guidelines on this. I tend to write about 95% of my comments using markdown because of the ability to format and style it. However, I do sometimes still write comments inside code chunks. I think I typically do this to explain how a specific piece of code in the chunk works rather than what the chunk is trying to do overall.
Add distinction between comments and headers to the end of chapter 7. Call it 7.7 Things to keep in mind when using R Markdown files. Or something like that. Refer back to 4.6.
2020-06-03 a student asked this question at the bottom of the lab:
"I’m still a bit confused on the difference between the this text and the #comment from the line above. I understand that the explanatory text can be formatted etc. in markdown, but is there any reason to use #comments in these files (or just in R scripts?) **After exporting to html, I now am assuming that the ## are headers"
Here was my answer, which I can probably use in the book:
Comments (as a concept) can be written in markdown documents or in R scripts. As you correctly pointed out, the syntax for writing comments (how to write them) differs depending on where you write them.
In R scripts: R scripts only allow comments that begin with #. Additionally, comments in R scripts can't really be formatted or styled.
In R Markdown files (including Notebooks): Comments can be written plain text anywhere in the Notebook file except inside a code chunk. Inside a code chunk, comments must still begin with #. Remember, code chunks are kind of like little individual R scripts.
In R Markdown files (including Notebooks): Comments can be formatted and styled using markdown syntax. In markdown syntax # represents a level-1 header, ## represents a level-2 header, ### represents a level-3 header and #### represents a level-4 header.
In R Markdown files (including Notebooks): When would you choose to write comments around code chunks with markdown vs. writing comments inside code chunks with #? This is a good question and I'm not aware of any specific guidelines on this. I tend to write about 95% of my comments using markdown because of the ability to format and style it. However, I do sometimes still write comments inside code chunks. I think I typically do this to explain how a specific piece of code in the chunk works rather than what the chunk is trying to do overall.