[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"])

HTH,

Jim

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

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

>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
>...

>mydata=data.frame(year=c(1970,...),snow.cover=c(6.5,...))

>hist(mydata) does not work.

>Many thanks.

>PR

______________________________________________
R-help at stat.math.ethz.ch mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help 
PLEASE do read the posting guide!
http://www.R-project.org/posting-guide.html




More information about the R-help mailing list