[R] Graphical Display of Values' Distribution

Philipp Pagel p.pagel at wzw.tum.de
Wed Sep 17 22:06:18 CEST 2008


> I therefore wish to examine all values of urban.long[,3] which are
> greater than 1.  I have tried the following, but receive error
> messages each time:

> > hist(urban.long[,3]>1)
> Error in hist.default(urban.long[, 3]> 1) : 'x' must be numeric
> > hist(urban.long[urban.long[,3]>1])
> Error in `[.data.frame`(urban.long, urban.long[, 3]> 1) :
>   undefined columns selected
> > hist(urban.long[urban.long[,3]>1])
> Error in `[.data.frame`(urban.long, urban.long[, 3]> 1) :
>   undefined columns selected
> > hist(as.numeric(urban.long[urban.long[,3]>1]))
> Error in `[.data.frame`(urban.long, urban.long[, 3]> 1) :
>   undefined columns selected
> > hist(as.numeric(as.character(urban.long[urban.long[,3]>1])))
> Error in `[.data.frame`(urban.long, urban.long[, 3]> 1) :
>   undefined columns selected

Again the probelm is the indeing being wrong. What you wand can be
achieved by this:

hist( urban.long[urban.long[,3]>1, 3] )

So your second approach was almost right but again did not return
column 3 as a vector.

You may also want to have a look at the manual page for the subset()
function which sometimes (or to some people) feels easier than logical
subsetting.

cu
	Philipp

-- 
Dr. Philipp Pagel
Lehrstuhl für Genomorientierte Bioinformatik
Technische Universität München
Wissenschaftszentrum Weihenstephan
85350 Freising, Germany
http://mips.gsf.de/staff/pagel



More information about the R-help mailing list