where to enter code

hi i am importing an excel file to use while making a report on RMarkdown. Where do i type the code example:
Babies <- read_excel("Desktop/Babies.xlsx")

without it appearing on my report.

thank you!


Put your code in a chunk, use the chunk-options to prevent it showing up in the final doc. In your case this would look like

```{r echo=false, message=false}

Babies <- read_excel("Desktop/Babies. xlsx")


Sorry, one back-tick too few..

{r echo=false, message = false}

ok will work on this thank you!

hi. i successfully made a chunk and imported the excel file (soil.xlsx). but after entering the code above, it resulted to an x mark at one part, may i pls be guided how to correct it? thank you!

Hi @purple ,

You now have actually created a chunk-in-chunk structure, which is confusing for knitr. Please remove the first line: ```{r} (l48: 3 backticks and curly-braced r) and the last line: ``` (l54: 3 backticks) from your code and you'll be fine. For YAML headings and structure, have a further look at R Markdown: The Definitive Guide

Good luck, JW

thank you! i followed and edited both lines. But after clicking knit, an error occurred. may i pls be guided to it? thank you!

Remove the space from soil. xlsx. It should be soil.xlsx.

thank you, i followed and and error occurred again. hope your guidance re this. thanks again!

Is the file on your desktop?

Try FALSE instead of false.

1 Like

yes, soil.xlsx is on my desktop. i also successfully imported it.

ok will work on this. thank you.

It should be the FALSE instead of false. In R the booleans are in capitals.

Hi i followed those and another error appeared. the file soil.xlsx is on my desktop pls see photo below. thanks!

Does that code run in a normal script outside of RMarkdown?

hi, do you mean on R? thanks.

i tried it on R and there was also an error. pls see photo below. thank you.

Yeah, but without the RMarkdown chunk. Also, just copy and paste the code or error. It is better than a screenshot.

ok that is noted. i also tried the code on R, without the chunk and the same error appeared. thank you.