How do you run code in between comments? I am a beginner at R?

how do i run code in between each question? I know it is a stupid question but I am truly stuck. Thank you in advance!

In RStudio, pressing Ctrl/Cmd + Enter on a line will send it to the console and execute it. If it's preceded by any comments, those will be sent as well. This looks like it may be a screenshot of an Rmarkdown document. Is that the case? If so, the code you write needs to be surrounded with three backticks above and below. Try pasting this into your document and pressing Ctrl/Cmd + Enter while your cursor is on the print() line.

print("Hello rmarkdown!")
1 Like

Yes it is an RMarkdown document!

1 Like

You might find the R Markdown "get started" website useful. It describes how to insert those code chunks among many other things:

1 Like

Great! Rmarkdown is an extremely powerful tool once you get friendly with it :muscle: So this also looks like a homework assignment of some sort. Is that the case as well? My guess is that you're supposed to add "code chunks" like I mentioned in my last reply that accomplish the instructions in the text. Please do note the homework policy here if you ever need help on coding problems:

1 Like

Yes it is a homework assignment! But I want to answer it on my own of course! Thank you so much for your help! I think I get the gist!

1 Like

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.