0

How do I fix the scale of the graph in R. looking at the x axis not all value is available as in the csv column for total accident case. I'm writing the simple code as below.

>barplot(table(try_$`Total Accident (K)`))

enter image description here Appreciate any help from all of you

DaveArmstrong
  • 18,377
  • 2
  • 13
  • 25
  • I'm not sure why you are using `table()` here. It's easier to help you if you include a simple [reproducible example](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) with sample input and desired output that can be used to test and verify possible solutions. Do not post pictures of data and code. – MrFlick Jan 21 '21 at 21:59

2 Answers2

0

R is actually doing exactly what you told it to do. You're asking it to plot the frequency distribution of total accidents, but my guess is that total accidents is unique for every observation. I think if you did barplot(try_$`Total Accident (K)`)) that would give you closer to what you want.

DaveArmstrong
  • 18,377
  • 2
  • 13
  • 25
0

use this code

library(ggplot2)

ggplot(aes(x=`Total Accident (K)`), data = try_) + geom_bar()
nithish08
  • 468
  • 2
  • 7