# R Markdown Knitting

Hello there!

I'm trying to knit one of my report form R Markdown. But its showing that it can't find the data when I'm clicking on Knit. Its showing:

The data has already been imported, structured & analysed in RStudio.

It's difficult to know the exact nature of the problem without a reprex. Have you imported the data in the R Markdown file (in a code chunk)? It is not sufficient that the data has been "imported, structured & analysed in RStudio"; it must be done in the R Markdown file you are trying to knit.

Dear, thanks for your quick response. Sorry to say I don't know what do you mean by 'reprex'. And I also don't know how to import the data in R Markdown, because I already have imported it in the Environment pane & also have loaded it in the RStudio. I am attaching the full R Markdown screenshots here. Please see.

This post explains what a [REPRoducible EXample (reprex)] is

You have to include in your Rmd file the same commands you used to "import it" (to load it actually) into your working environment. The reason for this is that when you knit an Rmd document the code gets executed in a clean environment other than the one you are currently working on so the data you have loaded interactively doesn't exist in that environment.

Posting screenshots is considered a bad practice here, post formatted code instead. Here is how to do it.

Thanks. But could you please be a little more specific on how will I

Thanks. But could you please be a little more specific on how will I include my .xlsx file in the R Markdown? I imported it in the Environment pane & wrote View() code to load the data in the RStudio. But I didn't know that it wont work in the R Markdown.

That's not what I said, I said that you need to include the commands to load the data into your working environment, I don't know with what packages you are working with but for example, if you use the readxl package to read an xlsx file, you will have to include a command like

Demo_Report <- read_excel("path\to\your\file.xlsx")


The View() command is not for loading data, it is just to visualize data that it is already loaded into memory.

This is what I needed in the first place from you. Thanks a lot.

I felt offended by your words. This is upsetting. Thanks anyway.

I'm sorry you felt that way, it was not my intention to upset you, I honestly don't understand how those words can be offensive to you. Maybe the problem is that I am not a native English speaker and we come from very different cultural backgrounds so we interpret things differently.

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.