Problem knitting rmarkdown file

Thank you. At least now it seems to be running. I have a new error:

R Error eval 190721

@andresrcs Can you help? (Grateful newbie)

This error typically occurs with read.csv() if the file you are attempting to load is not in the same working directory as the RMarkdown file. Or similarly if the path is not set correctly. Or if the file name isn't quite right.

What is the specific line of code at (and around) line 145?

@bloosmore Thanks!

image

Hmmm... Maybe a few lines before that? I'm looking for the read.csv() function call. Where does data get assigned (that you then use in line 150)?

@bloosmore
image

Weird. Are you sure the error is still occurring on line 145? And, maybe you could upload all of the file because I'm still not seeing where you originally load data?

If you put the data within an R chunk within the response, people on this site can see, copy and then test your code.

@bloosmore
Thanks but this is a proprietary code and I don't feel comfortable loading the whole code onto a public forum. Is there anything else you can recommend?

Your problem seems to be that you are skipping the part where you load "data" into memory. Have in mind that when you knit a file, the code gets executed in a clean environment so it is not going to have access to the data you already have in your current working environment, you have to explicitly include all the code needed to load the data from scratch.

Actually, the better way to go about this is not to share your actual code but to make a minimal REPRoducible EXample (reprex) representative of your issue.

BTW, I splited this thread into a new topic just for the sake of keeping things tidy. Topics should contained only a single reasonably well defined question or issue.

Understood. Somewhere above that code is a line that says something like data <- read.csv("foobar.csv") or similar. My guess is that the error you're seeing indicates R can't find "foobar.csv". If that's right, you could either:

  1. Add an R chunk of
getwd()

and run just that chunk to confirm that R is looking in correct directory. If not, you could use setwd() to change it. Make sure you do this in the RMarkdown file, not from the console.

  1. In lieu of knitting, does the code chunk run correctly when using the "Run Current Chunk" (green play button)? If so, it may be what @andresrcs is saying about the clean environment.

@bloosmore
I ran the chunk as suggested and there is an error on line 152:
image

From console:
image

That can be a tough error to debug. It generally means you're attempting to access a function like a vector or data frame (using the []), but in your case, I wonder if it's not related to the previous data loading issue.

R doesn't seem to like the expression: raw_fusion$Sample ID. First, what is stored in Sample ID? Make sure that's what you expect. Then you might make sure raw_fusion$Sample ID is extracting the column you intend.

Can you create a small version of this code the reproduces the error, with the data included, with possibly just a few 'dummy' rows of data since I know it's proprietary? This is the reprex mentioned earlier. Otherwise it will be difficult to help you debug this.

@andresrcs @bloosmore

Me again.

Seem to be doing ok with RMarkdown and knitting until finalizing the pdf. Here is the error:
image

Any ideas where I need to look or what i need to do?

Unfortunately I don't. I usually knit to html, not pdf. Seems like it's a Latex error. Possibly something related to the figure labels. But it's hard to tell without the code.

Following R's error message, what does the log file show? You might comment out that specific figure to verify that's where the issue lies.

It is possible that this error happens because you are using a special character somewhere. In your figure label for example. Can you check this ?

@cderv
I can't see any unusual characters. The log shows:
image

These are the lines which use "label" in the .tex

You seem to have an _ in one of the label. Underscore are not well supported for that in LaTeX. Can you try by replacing it ?

@cderv
With some help, we have managed to run the script but we have had to remove a line of the code. I was hoping someone could tell me (in simple terms) what the code does!

knit: (function(inputFile, encoding) { rmarkdown::render(inputFile, encoding = encoding, output_file = file.path(dirname(inputFile), paste(format(Sys.time(), '%Y-%m-%d-%H-%M'),'_Sarcoma_Analysis&Graphs.pdf')) )})

I suppose this was in YAML ?

This is a way to change the behavior of the Knit button in the RSTUDIO IDE by using a custom render with some parameter. It only apply when you knit with the button.