I want to create a histogram, my data is stored in a variable Z
. Calling hist(Z)
is showing an error. I tried changing Z
to numeric but it is still showing errors:
Z=as.numeric(Z)
Error: (list) object cannot be coerced to type 'double'
year <- c(2010, 2011, 2012, 2013)
disconnected_ppl <- c(116, 54, 310, 110)
df <- data.frame(year=year, disconnected_ppl=disconnected_ppl)
df
year disconnected_ppl
2010 116
2011 54
2012 310
2013 110
I want to create a histogram of year on xlab
and disconnected_ppl
on ylab
. Each bar plot should be mentioned by the years and names on both the axis but I got the graph in this way:
As am new to R
can you please suggest me which is the right option to choose histograms or bar plot?