[R] Histograms per coding variable

Smit, A, Albertus, Dr ajsmit at botzoo.uct.ac.za
Wed Dec 5 12:49:08 CET 2001


Dear all

I have a dataset that looks like:

	fr.wt		site
1	4400		glen
2	235		glen
3	225		glen
'	'		'
'	'		'
'	'		'
82	550		glen
83	550		kom
84	550		kom
'	'		'
'	'		'
'	'		'
191	820		kom
192	2000		soet
'	'		'
'	'		'

I need to do a series of histograms for each of the codes, levels or 
factors in 'site'.  For the first one, 'glen', I would do:

>hist(fr.wt[1:82], nclass = 20)

for the second, 'kom':

>hist(fr.wt[83:191], nclass = 20)

and so on.

Is there are more elegant way to do this without having to use the 
fr.wt[1:82] bit?  I.e., how else can one extract the fr.wt data 
relevant to each code in the 'site' column?  If there is, say, 20 
codes in the 'site' column, how can one produce a histogram for each 
without having the retype the hist() bit for each code individually?

I am sure there is an easy solution which I am overlooking.

Thanks for the help,
Albertus


Dr Albertus J. Smit
Department of Botany
University of Cape Town
PO Box Rondebosch
7700
SOUTH AFRICA
Tel. 689 3032
Fax. 650 4041

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list