Reputation:
I have this dataset :
dat<-read.table(text = "pl Freq
Abid 23
Berl 54
Cara 54
Daka 10",header=T)
I am trying to have an histogram with the name of each columns (under the columns (i.e. "pl" informations) and the columns sorted in decreasing order... I tried a lot of ordering method, but :
barplot(dat$freq)
Seems to not be the good way...
I you have any idea that would be helpfull !
Cheers,
R.
Upvotes: 1
Views: 5213
Reputation: 259
I beieve this is what you are looking for:
barplot(dat$Freq, names.arg = dat$pl)
And if you want to have the barplot sorted according to their frequencies:
dat <- dat[order(dat$Freq, decreasing = TRUE), ]
Thomas
Upvotes: 3