my dataframe currently looks like this
N = 61
MChange <- rnorm(N)
FChange <- rnorm(N)
Industry <- sample(N)
industry020406 <- data.frame(Industry, MChange, FChange)
Using the following code:
ggplot(industry020406, aes(reorder(Industry, MChange), MChange)) +
geom_col() +
labs(x = "Industry",
y = "Tariff Cut (Percentage Points)") +
theme(axis.text.x = element_text(angle = 90))+
coord_flip()
my barchart looks like this:
Since it is difficult to identify changes that are significant, is there a way I can filter out MChange that is between -1 and 1 within the ggplot function?
Thank you.
>Solution :
You can do the filtering in xlim():
ggplot(industry020406, aes(reorder(Industry, MChange), MChange)) +
geom_col() +
coord_flip() +
xlim(sort(reorder(Industry, MChange)[MChange >= -1 & MChange <= 1]))

