[R] Problem with levelplot() in a loop

John Kane jrkrideau at inbox.com
Wed Feb 20 22:49:57 CET 2013


I think you need a print command in there

John Kane
Kingston ON Canada


> -----Original Message-----
> From: nikhiljoshi at gmail.com
> Sent: Wed, 20 Feb 2013 16:38:56 -0500
> To: r-help at r-project.org
> Subject: [R] Problem with levelplot() in a loop
> 
> Dear R users,
> I am trying to print heatmaps in a loop (with a pause).  Idea is to
> visualize changing correlations over time and for testing I wrote this
> simple (reproducible) code below.
> My problem is that levelplot() does not produce any output when I run the
> code (though heatmap does).  Ideally I would like to use levelplot() as
> it
> produces a neat index on the side indicating the color and the
> correlation
> value that it corresponds to while heatmap does not.  Any pointers as to
> how I can make levelplot() produce output in the loop or get heatmap to
> procude a nice index like levelplot() does?
> ps- To see the output with heatmap in a loop, just uncomment the
> heatmap()
> line and comment out the levelplot() line
> 
> col.l <- colorRampPalette(c('blue', 'green', 'yellow', 'red'))(30)
> for (i in 1:10)
> {
>   randmat <-
> cbind(rnorm(100),rnorm(100),rnorm(100),rnorm(100),rnorm(100))
>   colnames(randmat) <- c('A','B','C','D','E')
>   cormat <- cor(randmat)
>   levelplot(cormat,xlab=NULL,ylab=NULL,main='Correlation Heat
> Map',col.regions=col.l)
> #  heatmap(cormat,col=col.l,Rowv=NA,
> Colv=NA,main=paste("Plot:",i,sep=''))
>   Sys.sleep(1)
> }
> 
> Thanks much in advance!
> 
> 	[[alternative HTML version deleted]]
> 
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

____________________________________________________________
FREE 3D MARINE AQUARIUM SCREENSAVER - Watch dolphins, sharks & orcas on your desktop!



More information about the R-help mailing list