[R] a question about the output of plot

Jim Lemon jim at bitwrit.com.au
Tue Apr 15 08:36:41 CEST 2014


On 04/15/2014 11:46 AM, meng wrote:
> Hi all:
> I met a question about the output of plot.
> I want to output 3 plots.
> Method1: by function histogram{lattice}
> Method2: by function hist{graphics}
>
>
> But method1 failed(the output is empty),and only method 2 works.
> I can't find out the reason,and many thanks for your help.
>
>
> #Method1---failed(the output is empty)
> library(lattice)
> for(i in 1:3)
> {
> x<-rnorm(10)
>
>
> jpeg(paste("e:\\hist_",i,".jpeg"))
> histogram(x)
> dev.off()
> }
>
>
>
>
> #Method 2---works
> for(i in 1:3)
> {
> x<-rnorm(10)
>
>
> jpeg(paste("e:\\hist_",i,".jpeg"))
> hist(x)
> dev.off()
> }
>
Hi meng,
Try:

print(histogram(x))

Jim




More information about the R-help mailing list