Reputation: 1522
I'm using a dynamic input variable button_var_fir
for a dashboard via flexdashboard and shiny and hence, I can't subset the dataframe each time via e.g. df$variable > value
or the like:
ggplot(df_scat, aes(!!input$button_var_fir, !!input$button_var_sec)) +
geom_boxplot(aes(fill= Gen_type), alpha = 0.5, alpha = 0.75) +
At the moment, the plot looks like
and as you can see, I would like to get rid of all those zeros. They are present because I replaced NAs with zeros but however, in plots like this, I don't have to keep those zero values and it would look much better and more reasonable without.
Upvotes: 0
Views: 2172
Reputation: 2290
Or by you could simply remove the zeroes with subset(dataset, variable!= 0)
in your ggplot
Sample code:
ggplot(subset(mtcars,am != 0), aes(x=factor(am), y=mpg))+
geom_point()
Upvotes: 1
Reputation: 79246
You could subset your data with which
:
df_scat[which(df_scat$your_column > 0),]
Here is an example:
ggplot(mtcars[which(mtcars$am>0),], aes(x=factor(am), y=mpg)) +
geom_point()
Upvotes: 1