Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Why is rmarkdown adding NA values to my ggplot when I knit the file?

I’ve been stuck on a particular problem. I’ve created an rmd file and everything is how I’d like it, however, when I knit the rmd file into any format (HTML, pdf, word) the rmd.file will produce the ggplots with NA values. On the other hand, if I run the code chunks in the rmd script it comes out how it should do with no NA values. Just to note there are no NA values to begin with. Any suggestions for how I could fix this?

images attached below:

plot 1 before knit

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

plot 1 after knit

plot 2 before knit

plot 2 after knit

>Solution :

I can’t try it myself without some reproducible example, but have you tried including drop_na() function?

all_trips_v2 %>% 
  drop_na() %>% ...

or maybe below

... arrange(user_type, weekday) %>% 
drop_na() %>% ...
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading