ggplot (based on means) with labels

Just a quick note- now that you got this far (!), you could look into the forcats package for reordering factors (

Also for formatting the geom_text above, you may want to look into the scales package, specifically the number function with the accuracy argument.

  +  geom_text(aes(label = scales::number(mean, accuracy = 0.1)))

" 1. You can call your axis the way you want (this is exactly why you should be using meaningful variable names instead of A1, B1, etc).
2. One way to manually specify the order is changing your variable class to factor and specifying levels factor(country, levels = c('Europe', 'Germany', 'UK')) ."

Sorry, I was not refering to 'Country' in the labs function but to country in gather and ggplot aes. I don't have 'country' variable in my data set so I suppose it needs to be declared somewhere...

The same answer, you can call the variable aggregator the way you prefer in the gather() call, check how the function works by reading the documentation ?gather

1 Like

I still cannot find a solution for your great lineplot. I have checked this problematic InterviewDate and I can see that its name is correct...Is it related to incorrect date format?

 $ InterviewDate: POSIXct, format: "2018-06-04 16:42:00" "2018-05-21 08:30:00" "2018-10-15 13:04:32" "2018-12-17 11:03:42" ...


If this is still the same error that you are seen, it has nothing to do with the date format.

Just to discard some common problems, try deliting the .Rdata file in your working directory (only if you are using this feature, but have in mind that this is going to drop the content of your environment for subsequent sessions) and restart your r session with Crtl + Shift + F10

Thank you again.
The only thing missing is adding labels for each data point...

You can do it exactly the same way as with the bar plot

geom_text(aes(label = round(A2TB_mean, 1))) +

And BTW the post that you mark as "solution" it has to be the answer to the original question (the one in the title of your topic".

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.