Home > Mobile >  Bar plot in r with categorical variable
Bar plot in r with categorical variable

Time:11-26

Its pretty straight forward but I am unable to do it in r

I want to plot the below information in bar plot with state in x axis.

state Avg_Earning
 A         200
 B         350
 C         280
 D         520

CodePudding user response:

Barplot will solve the problem.

Data <- data.frame(state = LETTERS[1:4], Avg_Earning = c(200, 350, 280, 520))

barplot(Data$Avg_Earning, names.arg = Data$state)
  •  Tags:  
  • r
  • Related