Home > front end >  Why is rmarkdown adding NA values to my ggplot when I knit the file?
Why is rmarkdown adding NA values to my ggplot when I knit the file?

Time:04-12

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

plot 1 after knit

plot 2 before knit

plot 2 after knit

CodePudding user response:

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() %>% ...
  • Related