Dear r-help, I've got data of the following structure 1979 93.428747 0 1979 87.298608 20 1979 78.506340 40 ... 1979 45.567890 340 1980 60.815289 0 1980 49.630904 20 1980 24.981362 40 ... The first column is year and the last one is the longitude. I need a set of graphs showing the dependence of the middle value on the longitude, for each year, situated one blow the other. I.e. 1979: --...---```--``--.. 1980: ...--``../``\...--- ... etc. Here characters ---...---``` denote the curve. The middle value is on the vertical axis and the latitude is on the horizontal axis of each graph. To do this I use xyplot function from the Lattice package: xyplot(ac15$"value"~ac15$lon|year,data=ac15, type="l", layout=c(1,24), xlab="Longitude", as.table=TRUE, bg="white" ); But I have some problems using it. Questions: 1. How to make xyplot to draw the year value in the strip above each graph instead of writing the word 'year'? 2. I'd like to produce a .png file with graphs without drawing them on the screen. I try: png(filename = "Rplot.png", width = 480, height = 1024, pointsize = 12, bg = "white"); trellis.device(device=getOption("png"), color = FALSE, bg = "white" ); xyplot.... [see above] But I get the error message: Error in trellis.device(device = getOption("png"), color = FALSE, bg = "white") : couldn't find function "device.call" Where's the problem? I use R 1.7.0 and Windows NT 4.0 workstation. Thank you for attention and help! -- Best regards Wladimir Eremeev mailto:wl at eimb.ru =========================================================================Research Scientist Leninsky Prospect 33, Space Monitoring & Ecoinformation Systems Sector, Moscow, Russia, 119071, Institute of Ecology, Phone: (095) 135-9972; Russian Academy of Sciences Fax: (095) 954-5534
On Tue, 6 May 2003, Wladimir Eremeev wrote:> 2. I'd like to produce a .png file with graphs without drawing them on > the screen. > > I try: > png(filename = "Rplot.png", width = 480, height = 1024, pointsize = 12, > bg = "white"); > > trellis.device(device=getOption("png"), > color = FALSE, > bg = "white" ); > > xyplot.... [see above] > > But I get the error message: > > Error in trellis.device(device = getOption("png"), color = FALSE, bg = "white") : > couldn't find function "device.call" > > Where's the problem?Thare is no option "png". Look at the help for trellis.device to see what you should be using as a `device' argument: it even lists how to use the png() device.> I use R 1.7.0 and Windows NT 4.0 workstation.-- Brian D. Ripley, ripley at stats.ox.ac.uk Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UK Fax: +44 1865 272595
Wladimir Eremeev wrote:> Dear r-help, > > I've got data of the following structure > 1979 93.428747 0 > 1979 87.298608 20 > 1979 78.506340 40 > ... > 1979 45.567890 340 > 1980 60.815289 0 > 1980 49.630904 20 > 1980 24.981362 40 > ... > > The first column is year and the last one is the longitude. > I need a set of graphs showing the dependence of the middle value on > the longitude, for each year, situated one blow the other. > I.e. > 1979: --...---```--``--.. > 1980: ...--``../``\...--- > ... > etc. > > Here characters ---...---``` denote the curve. > The middle value is on the vertical axis > and the latitude is on the horizontal axis of each graph. > > To do this I use xyplot function from the Lattice package: > > xyplot(ac15$"value"~ac15$lon|year,data=ac15, > type="l", > layout=c(1,24), > xlab="Longitude", > as.table=TRUE, > bg="white" > ); > > But I have some problems using it. > > Questions: > > 1. How to make xyplot to draw the year value in the strip above each > graph instead of writing the word 'year'?Look at ?strip.default and try style = 4, or style = 5: fooData <- data.frame( year = factor(rep(2001:2010, each = 20)), y = rnorm(200), x = rep(1:20, time = 10)) library(lattice) trellis.device(bg = "white") xyplot(y ~ x | year, data = fooData, type = "l", layout = c(1, 10), xlab = "Longitude", as.table = TRUE, strip = function(...) strip.default(style = 5,...) )> > 2. I'd like to produce a .png file with graphs without drawing them on > the screen.Look at ?trellis.device: trellis.device(bg = "white", device = "png", filename = "d:/analyses/fig1.png") xyplot(y ~ x | year, data = fooData, type = "l", layout = c(1, 10), xlab = "Longitude", as.table = TRUE, strip = function(...) strip.default(style = 5,...) ) dev.off() Best, Renaud> > I try: > png(filename = "Rplot.png", width = 480, height = 1024, pointsize = 12, > bg = "white"); > > trellis.device(device=getOption("png"), > color = FALSE, > bg = "white" ); > > xyplot.... [see above] > > But I get the error message: > > Error in trellis.device(device = getOption("png"), color = FALSE, bg = "white") : > couldn't find function "device.call" > > Where's the problem? > > I use R 1.7.0 and Windows NT 4.0 workstation. > > Thank you for attention and help! >-- Dr Renaud Lancelot, v?t?rinaire CIRAD, D?partement Elevage et M?decine V?t?rinaire (CIRAD-Emvt) Programme Productions Animales http://www.cirad.fr/fr/pg_recherche/page.php?id=14 ISRA-LNERV tel +221 832 49 02 BP 2057 Dakar-Hann fax +221 821 18 79 (CIRAD) Senegal e-mail renaud.lancelot at cirad.fr
Is there any neat way of producing character-based "dumb" plots in R rather than the ordinary very good-looking graphics? It would at times be both easy and sufficient to include such crude graphs in HTML pages rather or similar. --robert
How about: Dat <- array(1:10, dim=c(10,2)) dimnames(Dat) <- list(NULL, c("x", "y")) Crt <- array(" ", dim=c(10,10)) Crt[Dat] <- "*" for(i in 1:10) cat(Crt[,11-i], "\n") This worked in both R 1.6.2 and S-Plus 6.1 under Windows 2000. hth. spencer graves Robert Lundqvist wrote:> Is there any neat way of producing character-based "dumb" plots in R > rather than the ordinary very good-looking graphics? It would at times be > both easy and sufficient to include such crude graphs in HTML pages rather > or similar. > > --robert > > ______________________________________________ > R-help at stat.math.ethz.ch mailing list > https://www.stat.math.ethz.ch/mailman/listinfo/r-help
On Tuesday 06 May 2003 03:23 am, Wladimir Eremeev wrote:> Dear r-help, > > I've got data of the following structure > 1979 93.428747 0 > 1979 87.298608 20 > 1979 78.506340 40 > ... > 1979 45.567890 340 > 1980 60.815289 0 > 1980 49.630904 20 > 1980 24.981362 40 > ... > > The first column is year and the last one is the longitude. > I need a set of graphs showing the dependence of the middle value on > the longitude, for each year, situated one blow the other. > I.e. > 1979: --...---```--``--.. > 1980: ...--``../``\...--- > ... > etc. > > Here characters ---...---``` denote the curve. > The middle value is on the vertical axis > and the latitude is on the horizontal axis of each graph. > > To do this I use xyplot function from the Lattice package: > > xyplot(ac15$"value"~ac15$lon|year,data=ac15, > type="l", > layout=c(1,24), > xlab="Longitude", > as.table=TRUE, > bg="white" > ); > > But I have some problems using it. > > Questions: > > 1. How to make xyplot to draw the year value in the strip above each > graph instead of writing the word 'year'?The simplest way would be to supply year as a factor, I think. xyplot(value ~ lon | factor(year), data=ac15, type="l", layout=c(1,24), xlab="Longitude", as.table=TRUE) The bg = "white" would have no effect here, as others have already pointed out. Deepayan