ggplot with conditions

It's hard to tell without the data, but I think the p you're plotting might be outside of your data frame.

Could you please turn this into a self-contained reprex (short for reproducible example)? You're almost there, it's just that since no one else has your test2.csv file, we can't re-create it. It will help us help you if we can be sure we're all working with/looking at the same stuff.

You can probably just include the tidied dataframe, since the focus of your problem is on ggplot.


If you've never heard of a reprex before, you might want to start by reading the help page. The reprex dos and don'ts are also useful.

What to do if you run into clipboard problems

If you run into problems with access to your clipboard, you can specify an outfile for the reprex, and then copy and paste the contents into the forum.

reprex::reprex(input = "fruits_stringdist.R", outfile = "")

For pointers specific to the community site, check out the reprex FAQ.

1 Like