0

Revisiting an issue that appears to have been asked before, but the answers aren't quite helping with the issue I'm experiencing.

I have a Markdown file that I'm trying to knit, with a code chunk of:

colnames(spreadspoke_scores)

When I attempt to knit the file, I get the below error:

Error in is.data.frame(x) : object(spreadspoke_scores) not found

This makes no sense to me since I can run the colnames function off this dataframe in the console.

I tried to knit a file with the below code just for fun:

colnames(cars)

And this ran just fine. So I'm confused, is there an intermediate step that needs to be taken to get R Markdown to recognize the dataframe?

Added: I added the below to the YAML section:

params: data: "spreadspoke_scores"

Which gets the knit to run, but then it comes back with #NULL results, so I don't think this is helping the issue.

Abartel
  • 21
  • 4
  • 1
    I'm just guessing (without a reproducible example), but ... do you have `spreadspoke_scores` already defined in your global environment and assume that the code in the markdown document will just "find" it? It doesn't work that way, documents must be self-contained and have all variables either explicitly defined within it (in the same or previous code block) or passed via [parameters](https://bookdown.org/yihui/rmarkdown/params-knit.html). – r2evans Dec 22 '22 at 15:53
  • I added the below to the YAML section: params: data: "spreadspoke_scores" Which gets the knit to run, but then it comes back with #NULL results, so I don't think this is helping the issue. – Abartel Dec 22 '22 at 21:12
  • There is very little we can do without a reproducible example. See https://stackoverflow.com/q/74887252/3358272 and https://stackoverflow.com/q/74887882/3358272 to see how to put a minimal yet complete rmarkdown document into a question on SO, noting the code-formatting within the question itself (paste the minimum rmarkdown, yaml-header/`\`\`\``-blocks and all, highlight all of that and then press `Ctrl-K` to indent it). As it stands, anything more on our part is mostly speculation. – r2evans Dec 22 '22 at 21:22

0 Answers0