[R] Newbie question: histogram

Felix Eschenburg Atropin75 at t-online.de
Wed Feb 4 14:51:20 CET 2004


Hello,
it looks like this is what you want.

year <- c(1970:1980)
> snow <- sample(10,length(year),replace=T)
> snow
 [1]  3  3  3  4  8  3  2  6  6  6 10
> year
 [1] 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980
> mydata <- data.frame(year,snow)
> attach(mydata)
> barplot(snow,names.arg=year,las=2)

for a histogram of snow you might try something like this
hist(snow,breaks=c((min(snow)-0.5):(max(snow)+0.5)))

Felix (who is a newbie himself, so excuse me please if i didnt get your 
problem)


Am Mittwoch, 4. Februar 2004 12:41 schrieb Philippe de Rochambeau:
> 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