[R] awkward behavior with densityplot function

Rolf Turner r.turner at auckland.ac.nz
Wed Aug 27 01:25:41 CEST 2008


See FAQ 7.22

On 27/08/2008, at 11:07 AM, John Sanabria wrote:

> Hi,
>
> I have the following script:
> ---- t.R ---
> grafica <- function() {
>   v <- read.csv('preprocessed/komolongma.ece.uprm.edu.active',sep=',')
>   x <- as.ts(v$active)
>   bitmap(file="output.png")
>   densityplot(~x,col='blue',main='Density Plot')
>   dev.off()
> }
> grafica()
> ---- t.R ---
>
> When I "sourced" it from R prompt, it quietly runs. However the  
> "output.png" generated contains any visible data. I said that,  
> because the file is created and it has 2062 bytes.
> --- execution ---
> > library(lattice)
> > source(file="t.R")
> >
> --- execution ---
>
> Now, if I sequentially run the lines above in the R prompt, the  
> "output.png" file contains a graphical representation of the data.
> --- execution 2 ----
> > v <- read.csv('preprocessed/komolongma.ece.uprm.edu.active',sep=',')
> > x <- as.ts(v$active)
> > bitmap(file="output.png")
> > densityplot(~x,col='blue',main='Density Plot')
> > dev.off()
> ---- execution 2 ---
>
> What is wrong with the densityplot function that produces any  
> output when is invoked from a script?
> Someone has a script invoking the densityplot function?

######################################################################
Attention:\ This e-mail message is privileged and confid...{{dropped:9}}



More information about the R-help mailing list