[R] Graphical Display of Values' Distribution

Steve Murray smurray444 at hotmail.com
Wed Sep 17 19:28:52 CEST 2008

Dear all,

I have a column within a dataframe of values which range between 1 and 2. I want to display graphically the distribution of these values (i.e. are they clustered towards either exteme? Or spread evenly?). What is a good way of doing this in R?

I've tried a few things, including using the 'hist' command, but receive the following error message:

> hist(urban.long[3])
Error in hist.default(urban.long[3]) : 'x' must be numeric

...which is strange because all the values *are* numeric!

I also tried to create a scatter graph, but it's difficult as there isn't anything obvious to go on the 'y' axis. I've tried to create some kind of 'frequency' axis using the 'sequence' function, but receive the following:

> plot(seq(0,1000,100),urban.long[3])
Error in xy.coords(x, y, xlabel, ylabel, log) : 
  'x' and 'y' lengths differ

...which is probably because I'm unable to tell how many of each value there are (which invalidates the 'sequence' argument perhaps?).

Maybe I'm taking the wrong approach! I'd be very grateful if someone could put me on the right tracks and guide me with the R commands.

Many thanks for any help offered,


More information about the R-help mailing list