Levelplot not working from file

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Levelplot not working from file

Matt Sakals
I am trying to use the levelplot function from a command file.
Here is the code:

library(sp)
library(gstat)
library(lattice)

gatherData <- read.table("~/gather.txt", header = TRUE)
grd = makegrid(gatherData$x, gatherData$y, cell.size = 5)
k <- krige(z~x+y, ~x+y, data = gatherData, newdata = grd, nmax = 5)

levelplot(var1.pred~x+y, k, aspect = mapasp(k), main = "Predicted 5m")

It executes fine (it plots up) when I cut and paste to the command
prompt but it seems to be missed (nothing occurs) when I call the
source file.
I am using OSX.
Thanks for any help.
Matt
        [[alternative text/enriched version deleted]]

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Reply | Threaded
Open this post in threaded view
|

Re: Levelplot not working from file

Bert Gunter
I think this is an FAQ. Anyway, levelplot() is a lattice plot and therefore
must be explicitly printed when source()ed or in a function; i.e.

print(levelplot(....))

is required.

-- Bert
 

> -----Original Message-----
> From: [hidden email]
> [mailto:[hidden email]] On Behalf Of Matt Sakals
> Sent: Tuesday, January 10, 2006 4:00 PM
> To: [hidden email]
> Subject: [R] Levelplot not working from file
>
> I am trying to use the levelplot function from a command file.
> Here is the code:
>
> library(sp)
> library(gstat)
> library(lattice)
>
> gatherData <- read.table("~/gather.txt", header = TRUE)
> grd = makegrid(gatherData$x, gatherData$y, cell.size = 5)
> k <- krige(z~x+y, ~x+y, data = gatherData, newdata = grd, nmax = 5)
>
> levelplot(var1.pred~x+y, k, aspect = mapasp(k), main = "Predicted 5m")
>
> It executes fine (it plots up) when I cut and paste to the command
> prompt but it seems to be missed (nothing occurs) when I call the
> source file.
> I am using OSX.
> Thanks for any help.
> Matt
> [[alternative text/enriched version deleted]]
>
> ______________________________________________
> [hidden email] mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide!
> http://www.R-project.org/posting-guide.html
>

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Reply | Threaded
Open this post in threaded view
|

Re: Levelplot not working from file

Sundar Dorai-Raj
In reply to this post by Matt Sakals
Hi, Matt,

See FAQ 7.22.

--sundar

Matt Sakals wrote:

> I am trying to use the levelplot function from a command file.
> Here is the code:
>
> library(sp)
> library(gstat)
> library(lattice)
>
> gatherData <- read.table("~/gather.txt", header = TRUE)
> grd = makegrid(gatherData$x, gatherData$y, cell.size = 5)
> k <- krige(z~x+y, ~x+y, data = gatherData, newdata = grd, nmax = 5)
>
> levelplot(var1.pred~x+y, k, aspect = mapasp(k), main = "Predicted 5m")
>
> It executes fine (it plots up) when I cut and paste to the command
> prompt but it seems to be missed (nothing occurs) when I call the
> source file.
> I am using OSX.
> Thanks for any help.
> Matt
> [[alternative text/enriched version deleted]]
>
> ______________________________________________
> [hidden email] mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html