# Problem of statistical graph.

Hello,

I have a data file, concerning a mileage record in the form ("First Name", "Date", Mileage ").

I would like to make a cross-tab with age and mileage, in order to have the mileage for each name. For that, I use the formula:

Tab = aggregate(data\$KM~data\$Prenom, data, sum)

And I come to this result:

data\$Prenom data\$KM
1 Abdel 13470
2 Corinne 11727
3 Fred 12108
4 Jacque 11115
5 Jean 10522
6 Jean-Pierre 11053
7 Julie 10503
8 Pierre 13277
9 Richard 10311

Unfortunately, I absolutely can not do a bar graph with Aggregate .... I do not know how to do it

Do you mean something like this?

``````# Sample data
Tab <- data.frame(stringsAsFactors=FALSE,
Prenom = c("Abdel", "Corinne", "Fred", "Jacque", "Jean", "Jean-Pierre",
"Julie", "Pierre", "Richard"),
KM = c(13470, 11727, 12108, 11115, 10522, 11053, 10503, 13277, 10311))
library(ggplot2)

ggplot(Tab, aes(x = Prenom, y = KM)) +
geom_col() +
coord_flip()
``````

Created on 2019-05-30 by the reprex package (v0.3.0)

Oh ! This is very simple whis GGplot. Thank you so much

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