-4

country cars deaths population

1 Belgium 467 112 10396 2 Czech Republic 373 135 10212 3 Denmark 354 68 5398 4 Germany 546 71 82532 5 Estonia 350 126 1351 6 Greece 348 147 11041 7 Spain 454 112 42345 8 France 491 92 59901 9 Ireland 385 94 4028 10 Italy 581 97 57888 11 Cyprus 448 160 730 12 Latvia 297 222 2319 13 Lithuania 384 218 3446 14 Luxembourg 659 109 452 15 Hungary 280 128 10117 16 Malta 525 33 400 17 Netherlands 429 49 16258 18 Austria 501 108 8114 19 Poland 314 150 38191 20 Portugal 572 124 10475 21 Slovenia 456 137 1996 22 Slovakia 222 112 5380 23 Finland 448 72 5220 24 Sweden 456 53 8976 25 United Kingdom 463 56 59652

I keep entering the following statement and it states "x" must be numeric and I have no clue why!

hist(cars,ylab = "Frecuencia por paises",xlab = "Automoviles por mil habitantes",main = "Histograma de automoviles por cada 1000 habitates",ylim = c(0,10),col = ("magenta"))

Roman Luštrik
  • 69,533
  • 24
  • 154
  • 197
  • `x` clearly isn't numeric. [Please show your dataset](http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) the way we can make at least an educated guess. A reproducible example would be the ultimate goal, though. – Roman Luštrik Mar 03 '17 at 11:53

1 Answers1

0

define your dataset (say as df)

#to convert cars column into numeric format
df$cars<-as.numeric(as.character(df$cars))

hist(df$cars,....)

... other arguements

Also u can try ggplot for better visualization

library(ggplot2)
ggplot(df, aes(Country,Cars))+geom_bar(stat="identity")
Ishan Juneja
  • 401
  • 4
  • 11