yihui / knitr-examples

A collection of knitr examples
488 stars 586 forks source link

Issues in knitting on ggplots #63

Open TeeMuchini opened 6 years ago

TeeMuchini commented 6 years ago

i am trying to knit gpplot code to pdf file and it gives me an error.The dataframe in R is called retailyoy and the plot is to show .The code run in R Markdown give me this output. image

but gives me problem when i am trying to knit.Below is error message:

"Error in ggplot(data = retailyoy, aes(x = retailyoy$Supplier Name, y = retailyoy$SALES_CHANGE, : object 'retailyoy' not found Calls: ... withCallingHandlers -> withVisible -> eval -> eval -> ggplot Execution halted"

Below is the chunk code:

library('ggplot2')
p1=ggplot(data=retailyoy, aes(x=retailyoy$`Supplier Name`, y=retailyoy$SALES_CHANGE, fill=DEPARTMENT, coord_cartesian(xlim = c(-200, 200))))+ geom_bar(stat="identity") +  coord_flip() + scale_fill_brewer(palette="Dark2") +  labs(title="YEAR ON YEAR GROWTH OF SALES",x="SUPPLIER NAME", y = "%YOY GROWTH")
p1+ geom_boxplot()