https://github.com/cran/gstat
Tip revision: 7b5f26a6317ea33e36572b02742c938176457712 authored by Edzer J. Pebesma on 08 October 2008, 18:06:07 UTC
version 0.9-51
version 0.9-51
Tip revision: 7b5f26a
na.action.Rout.save
R version 2.6.0 (2007-10-03)
Copyright (C) 2007 The R Foundation for Statistical Computing
ISBN 3-900051-07-0
R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.
R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.
Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.
> library(gstat)
Loading required package: sp
>
> data(meuse)
> data(meuse.grid)
>
> set.seed(13131) # reproduce results
>
> # select 10 random rows;
> # create two missing values in the coordinates:
> m = meuse.grid[sample(nrow(meuse.grid), 10), ]
> m[c(2,8), "x"] = NA
>
> ## this is not allowed anymore:
> try(krige(log(zinc)~1,~x+y,meuse,m, na.action = na.pass))
Error in validityMethod(object) :
number of rows in data.frame and SpatialPoints don't match
> try(krige(log(zinc)~1,~x+y,meuse,m, na.action = na.omit))
Error in validityMethod(object) :
number of rows in data.frame and SpatialPoints don't match
> try(krige(log(zinc)~1,~x+y,meuse,m, na.action = na.exclude))
Error in validityMethod(object) :
number of rows in data.frame and SpatialPoints don't match
> try(krige(log(zinc)~1,~x+y,meuse,m, na.action = na.fail))
Error in validityMethod(object) :
number of rows in data.frame and SpatialPoints don't match
>
> # select 10 random rows;
> # create two missing values in the regressor variable:
> m = meuse.grid[sample(nrow(meuse.grid), 10), ]
> m[c(3,7), "dist"] = NA
> krige(log(zinc)~dist,~x+y,meuse,m, na.action = na.pass)
[ordinary or weighted least squares prediction]
x y var1.pred var1.var
1 180260 331740 5.110655 0.2425253
2 180420 331180 4.024709 0.2580362
3 178740 330740 NA NA
4 178780 330180 5.815051 0.2392971
5 180900 333220 6.343871 0.2404070
6 179980 331580 5.272101 0.2413105
7 180740 332300 NA NA
8 180660 330140 6.462357 0.2410713
9 179980 331700 5.345455 0.2408518
10 179540 329900 6.314501 0.2402659
> krige(log(zinc)~dist,~x+y,meuse,m, na.action = na.omit)
[ordinary or weighted least squares prediction]
x y var1.pred var1.var
1 180260 331740 5.110655 0.2425253
2 180420 331180 4.024709 0.2580362
3 178780 330180 5.815051 0.2392971
4 180900 333220 6.343871 0.2404070
5 179980 331580 5.272101 0.2413105
6 180660 330140 6.462357 0.2410713
7 179980 331700 5.345455 0.2408518
8 179540 329900 6.314501 0.2402659
> krige(log(zinc)~dist,~x+y,meuse,m, na.action = na.exclude)
[ordinary or weighted least squares prediction]
x y var1.pred var1.var
1 180260 331740 5.110655 0.2425253
2 180420 331180 4.024709 0.2580362
3 178780 330180 5.815051 0.2392971
4 180900 333220 6.343871 0.2404070
5 179980 331580 5.272101 0.2413105
6 180660 330140 6.462357 0.2410713
7 179980 331700 5.345455 0.2408518
8 179540 329900 6.314501 0.2402659
> try(krige(log(zinc)~dist,~x+y,meuse,m, na.action = na.fail))
Error in na.fail.default(structure(list(dist = c(0.527108, 0.929323, NA, :
missing values in object
>