Perfectly run in RMarkdown but Issue when Knit to HTML

Good day everyone, need help to confirm that is there a bug during HTML rendering !?

  1. I got a simple data frame from an operation,
  2. then I remove the second column that has no name ""
  3. then operate mutate and arrange

All were perfectly operated in RMarkdown but when I knit it to HTML, there is an error saying "Confidence" not found. Confidence is a variable and it is found when I operated otherwise the mutate operation would have failed. I think it is an error or bug,. I have tried many different ways but I just cannot get HTML rendereed, found that it could be caused by bug somewhere.

Please correct me.

Thanks!

Kar

From what I can see in your screenshot, there is no bug. You simply have forgot to assign the changes to a variable, dplyrdoesn't perform in-place modifications, it returns a new data frame instead, if you want changes to persist, you have to explicitly assign them to a variable with the assign operator (<-).

If you need more specific help, please provide a proper REPRoducible EXample (reprex) illustrating your issue.

Hi mate,

No, I didn't forget, I have been using R for 7 years. And dplyr does perform in-place modifications, plus, if it doesn't the RMarkdown result chunk would be fail to give the modified data frame, but it succeeded.

image

For sure, if I want change to persist the changes I have to assign it to an object or replace the original object.

What strange is that everything was successfully run in RMarkdown, but interestingly failed to render to HTML.

Best

Kar

My bad, in my defense, debugging from a screenshot is far from ideal, sorry if I have offended your experienced programmer sensitivity. Any chance you can produce a reproducible example?

About this, I think we are not talking about the same thing, as you said as well, explicit assignment is required, dplyr functions do not perform in-place modification on their own.

All good mate, I didn't feel offended at all.

Sorry I wasn't clear. I meant "dplyr does perform in-place modifications under the context of RMarkdown for temporary display only (see the RMarkdown picture of the result chunk under the code chunk), if permanent modifications are to be made, one should use the assign operator. "

That's why I said the two sentences and also why I said "dplyr does perform in-place modifications" because I am showing my example in RMarkdown with the output chunk under the code chunk. Anyway, it is not the point, and either the way whether I have used the assignment operator or not, it will not affect the HTML rendering and the HTML file should still be rendered. It is the strange part.

Thank you for your information. Sorry, I do not have an reproducible example..

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.