[R] Newbie question: histogram

James MacDonald jmacdon at med.umich.edu
Wed Feb 4 15:25:57 CET 2004

You don't make a histogram with a data.frame. You have to pass a vector
of numeric values to hist(). If you want to make a histogram using a
*column* of a df, you have to subset the df in the call to hist.

hist(mydata[,1]) -or- hist(mydata[,"year"])
hist(mydata[,2]) - or- hist(mydata[,"snow.cover"])



James W. MacDonald
Affymetrix and cDNA Microarray Core
University of Michigan Cancer Center
1500 E. Medical Center Drive
7410 CCGC
Ann Arbor MI 48109

>>> Philippe de Rochambeau <philippe at wwphi.net> 02/04/04 06:41AM >>>

>how do you create a histogram with a data frame?

>year snow.cover
>1970 6.5
>1971 12.0
>1972 14.9
>1973 10.0
>1974 10.7
>1975 7.9


>hist(mydata) does not work.

>Many thanks.


R-help at stat.math.ethz.ch mailing list
PLEASE do read the posting guide!

More information about the R-help mailing list