Sie sind auf Seite 1von 31

R version 3.2.

1 (2015-06-18) -- "World-Famous Astronaut"


Copyright (C) 2015 The R Foundation for Statistical Computing
Platform: x86_64-w64-mingw32/x64 (64-bit)

R es un software libre y viene sin GARANTIA ALGUNA.


Usted puede redistribuirlo bajo ciertas circunstancias.
Escriba 'license()' o 'licence()' para detalles de distribucion.

R es un proyecto colaborativo con muchos contribuyentes.


Escriba 'contributors()' para obtener ms informacin y
'citation()' para saber cmo citar R o paquetes de R en publicaciones.

Escriba 'demo()' para demostraciones, 'help()' para el sistema on-line de


ayuda,
o 'help.start()' para abrir el sistema de ayuda HTML con su navegador.
Escriba 'q()' para salir de R.

> 2+2
[1] 4
>x
Error: objeto 'x' no encontrado
> x<-2
>x
[1] 2
> x+x
[1] 4
> y<-x+x
>y
[1] 4

> peso<-c(60,70,80,90,100)
> peso
[1] 60 70 80 90 100
> Enorm(15)
Error: no se pudo encontrar la funcin "Enorm"
> Ernorm(15)
Error: no se pudo encontrar la funcin "Ernorm"
> Enorm(15)
Error: no se pudo encontrar la funcin "Enorm"
> rnorm(15)
[1] -0.09156132 0.27116751 1.14782468 -0.93962827 1.82457948
-0.67277553
[7] 0.59714 248 -1.28884141 2.40275865 -0.25590020 -0.47069998
-0.08833632
[13] 0.66677849 0.51115291 -1.96689498
> al<-rnorm(15)
> al
[1] 0.22074328 -2.03384002 1.48783896 0.87069384 2.84172017
-0.73843798
[7] 1.11238844 -0.09468982 -0.54074205 1.82273762 1.60791268
1.20035212
[13] -0.25661125 0.71722739 -0.95860322
> al[13]
[1] -0.2566113
> mean(al)
[1] 0.4839127
> max(al)
[1] 2.84172
> min(al)
[1] -2.03384
> sum(al)

[1] 7.25869
> al[al>0]
[1] 0.2207433 1.4878390 0.8706938 2.8417202 1.1123884 1.8227376
1.6079127
[8] 1.2003521 0.7172274
> max(peso)
[1] 100
> demo()
> demo(graphica)
Error in demo(graphica) : No demo found for topic graphica
> demo(graphics)

demo(graphics)
---- ~~~~~~~~

Type <Return> to start :

> # Copyright (C) 1997-2009 The R Core Team


>
> require(datasets)

> require(grDevices); require(graphics)

> ## Here is some code which illustrates some of the differences between
> ## R and S graphics capabilities. Note that colors are generally specified
> ## by a character string name (taken from the X11 rgb.txt file) and that line
> ## textures are given similarly. The parameter "bg" sets the background
> ## parameter for the plot and there is also an "fg" parameter which sets
> ## the foreground color.

>
>
> x <- stats::rnorm(50)

> opar <- par(bg = "white")

> plot(x, ann = FALSE, type = "n")


Esperando para confirmar cambio de pgina...

> abline(h = 0, col = gray(.90))

> lines(x, col = "green4", lty = "dotted")

> points(x, bg = "limegreen", pch = 21)

> title(main = "Simple Use of Color In a Plot",


+

xlab = "Just a Whisper of a Label",

col.main = "blue", col.lab = gray(.8),

cex.main = 1.2, cex.lab = 1.0, font.main = 4, font.lab = 3)

> ## A little color wheel.


> ## a pie chart.

This code just plots equally spaced hues in

If you have a cheap SVGA monitor (like me) you will

> ## probably find that numerically equispaced does not mean visually
> ## equispaced. On my display at home, these colors tend to cluster at
> ## the RGB primaries. On the other hand on the SGI Indy at work the
> ## effect is near perfect.
>
> par(bg = "gray")

> pie(rep(1,24), col = rainbow(24), radius = 0.9)

Esperando para confirmar cambio de pgina...

> title(main = "A Sample Color Wheel", cex.main = 1.4, font.main = 3)

> title(xlab = "(Use this as a test of monitor linearity)",


+

cex.lab = 0.8, font.lab = 3)

> ## We have already confessed to having these. This is just showing off X11
> ## color names (and the example (from the postscript manual) is pretty
"cute".
>
> pie.sales <- c(0.12, 0.3, 0.26, 0.16, 0.04, 0.12)

> names(pie.sales) <- c("Blueberry", "Cherry",


+

"Apple", "Boston Cream", "Other", "Vanilla Cream")

> pie(pie.sales,
+

col = c("purple","violetred1","green3","cornsilk","cyan","white"))

Esperando para confirmar cambio de pgina...

> title(main = "January Pie Sales", cex.main = 1.8, font.main = 1)

> title(xlab = "(Don't try this at home kids)", cex.lab = 0.8, font.lab = 3)

> ## Boxplots: I couldn't resist the capability for filling the "box".
> ## The use of color seems like a useful addition, it focuses attention
> ## on the central bulk of the data.
>
> par(bg="cornsilk")

> n <- 10

> g <- gl(n, 100, n*100)

> x <- rnorm(n*100) + sqrt(as.numeric(g))

> boxplot(split(x,g), col="lavender", notch=TRUE)


Esperando para confirmar cambio de pgina...

> title(main="Notched Boxplots", xlab="Group", font.main=4, font.lab=1)

> ## An example showing how to fill between curves.


>
> par(bg="white")

> n <- 100

> x <- c(0,cumsum(rnorm(n)))

> y <- c(0,cumsum(rnorm(n)))

> xx <- c(0:n, n:0)

> yy <- c(x, rev(y))

> plot(xx, yy, type="n", xlab="Time", ylab="Distance")


Esperando para confirmar cambio de pgina...

> polygon(xx, yy, col="gray")

> title("Distance Between Brownian Motions")

> ## Colored plot margins, axis labels and titles.


> ## careful with these kinds of effects.

You do need to be

It's easy to go completely

> ## over the top and you can end up with your lunch all over the keyboard.
> ## On the other hand, my market research clients love it.
>
> x <- c(0.00, 0.40, 0.86, 0.85, 0.69, 0.48, 0.54, 1.09, 1.11, 1.73, 2.05, 2.02)

> par(bg="lightgray")

> plot(x, type="n", axes=FALSE, ann=FALSE)


Esperando para confirmar cambio de pgina...

> usr <- par("usr")

> rect(usr[1], usr[3], usr[2], usr[4], col="cornsilk", border="black")

> lines(x, col="blue")

> points(x, pch=21, bg="lightcyan", cex=1.25)

> axis(2, col.axis="blue", las=1)

> axis(1, at=1:12, lab=month.abb, col.axis="blue")

> box()

> title(main= "The Level of Interest in R", font.main=4, col.main="red")

> title(xlab= "1996", col.lab="red")

> ## A filled histogram, showing how to change the font used for the
> ## main title without changing the other annotation.
>
> par(bg="cornsilk")

> x <- rnorm(1000)

> hist(x, xlim=range(-4, 4, x), col="lavender", main="")


Esperando para confirmar cambio de pgina...

> title(main="1000 Normal Random Variates", font.main=3)

> ## A scatterplot matrix


> ## The good old Iris data (yet again)
>
> pairs(iris[1:4], main="Edgar Anderson's Iris Data", font.main=4, pch=19)
Esperando para confirmar cambio de pgina...

> pairs(iris[1:4], main="Edgar Anderson's Iris Data", pch=21,


+

bg = c("red", "green3", "blue")[unclass(iris$Species)])

Esperando para confirmar cambio de pgina...

> ## Contour plotting


> ## This produces a topographic map of one of Auckland's many volcanic
"peaks".
>
> x <- 10*1:nrow(volcano)

> y <- 10*1:ncol(volcano)

> lev <- pretty(range(volcano), 10)

> par(bg = "lightcyan")

> pin <- par("pin")

> xdelta <- diff(range(x))

> ydelta <- diff(range(y))

> xscale <- pin[1]/xdelta

> yscale <- pin[2]/ydelta

> scale <- min(xscale, yscale)

> xadd <- 0.5*(pin[1]/scale - xdelta)

> yadd <- 0.5*(pin[2]/scale - ydelta)

> plot(numeric(0), numeric(0),


+

xlim = range(x)+c(-1,1)*xadd, ylim = range(y)+c(-1,1)*yadd,

type = "n", ann = FALSE)

Esperando para confirmar cambio de pgina...

> usr <- par("usr")

> rect(usr[1], usr[3], usr[2], usr[4], col="green3")

> contour(x, y, volcano, levels = lev, col="yellow", lty="solid", add=TRUE)

> box()

> title("A Topographic Map of Maunga Whau", font= 4)

> title(xlab = "Meters North", ylab = "Meters West", font= 3)

> mtext("10 Meter Contour Spacing", side=3, line=0.35, outer=FALSE,


+

at = mean(par("usr")[1:2]), cex=0.7, font=3)

> ## Conditioning plots


>
> par(bg="cornsilk")

> coplot(lat ~ long | depth, data = quakes, pch = 21, bg = "green3")


Esperando para confirmar cambio de pgina...

> par(opar)
>
> demo(colors)

demo(colors)
---- ~~~~~~

Type <Return> to start :

> ### ----------- Show (almost) all named colors ---------------------

>
> ## 1) with traditional 'graphics' package:
> showCols1 <- function(bg = "gray", cex = 0.75, srt = 30) {
+

m <- ceiling(sqrt(n <- length(cl <- colors())))

length(cl) <- m*m; cm <- matrix(cl, m)

##

require("graphics")

op <- par(mar=rep(0,4), ann=FALSE, bg = bg); on.exit(par(op))

plot(1:m,1:m, type="n", axes=FALSE)

text(col(cm), rev(row(cm)), cm, col = cl, cex=cex, srt=srt)

+}

> showCols1()
Esperando para confirmar cambio de pgina...

> ## 2) with 'grid' package:


> showCols2 <- function(bg = "grey", cex = 0.75, rot = 30) {
+

m <- ceiling(sqrt(n <- length(cl <- colors())))

length(cl) <- m*m; cm <- matrix(cl, m)

##

require("grid")

grid.newpage(); vp <- viewport(w = .92, h = .92)

grid.rect(gp=gpar(fill=bg))

grid.text(cm, x = col(cm)/m, y = rev(row(cm))/m, rot = rot,

vp=vp, gp=gpar(cex = cex, col = cm))

+}

> showCols2()
Loading required package: grid
Esperando para confirmar cambio de pgina...

> showCols2(bg = "gray33")


Esperando para confirmar cambio de pgina...

> ###
>
> ##' @title Comparing Colors
> ##' @param col
> ##' @param nrow
> ##' @param ncol
> ##' @param txt.col
> ##' @return the grid layout, invisibly
> ##' @author Marius Hofert, originally
> plotCol <- function(col, nrow=1, ncol=ceiling(length(col) / nrow),
+

txt.col="black") {

stopifnot(nrow >= 1, ncol >= 1)

if(length(col) > nrow*ncol)

warning("some colors will not be shown")

require(grid)

grid.newpage()

gl <- grid.layout(nrow, ncol)

pushViewport(viewport(layout=gl))

ic <- 1

for(i in 1:nrow) {

for(j in 1:ncol) {

pushViewport(viewport(layout.pos.row=i, layout.pos.col=j))

grid.rect(gp= gpar(fill=col[ic]))

grid.text(col[ic], gp=gpar(col=txt.col))

upViewport()

ic <- ic+1

upViewport()

invisible(gl)

+}

> ## A Chocolate Bar of colors:


> plotCol(c("#CC8C3C", paste0("chocolate", 2:4),
+

paste0("darkorange", c("",1:2)), paste0("darkgoldenrod", 1:2),

"orange", "orange1", "sandybrown", "tan1", "tan2"),

nrow=2)

Esperando para confirmar cambio de pgina...

> ##' Find close R colors() to a given color {original by Marius Hofert)
> ##' using Euclidean norm in (HSV / RGB / ...) color space
> nearRcolor <- function(rgb, cSpace = c("hsv", "rgb255", "Luv", "Lab"),
+

dist = switch(cSpace, "hsv" = 0.10, "rgb255" = 30,

"Luv" = 15, "Lab" = 12))

+{
+

if(is.character(rgb)) rgb <- col2rgb(rgb)

stopifnot(length(rgb <- as.vector(rgb)) == 3)

Rcol <- col2rgb(.cc <- colors())

uniqC <- !duplicated(t(Rcol)) # gray9 == grey9 (etc)

Rcol <- Rcol[, uniqC] ; .cc <- .cc[uniqC]

cSpace <- match.arg(cSpace)

convRGB2 <- function(Rgb, to)

t(convertColor(t(Rgb), from="sRGB", to=to, scale.in=255))

## the transformation, rgb{0..255} --> cSpace :

TransF <- switch(cSpace,

"rgb255" = identity,

"hsv" = rgb2hsv,

"Luv" = function(RGB) convRGB2(RGB, "Luv"),

"Lab" = function(RGB) convRGB2(RGB, "Lab"))

d <- sqrt(colSums((TransF(Rcol) - as.vector(TransF(rgb)))^2))

iS <- sort.list(d[near <- d <= dist])# sorted: closest first

setNames(.cc[near][iS], format(d[near][iS], digits=3))

+}

> nearRcolor(col2rgb("tan2"), "rgb")


0.0
"tan2"

21.1

25.8

29.5

"tan1" "sandybrown"

"sienna1"

> nearRcolor(col2rgb("tan2"), "hsv")


0.0000
"tan2"
0.0778

0.0410

0.0618

0.0638

"sienna2"

"coral2"

"tomato2"

0.0900

0.0912

0.0918

"sienna1" "sandybrown"

"coral1"

0.0667

0.0766

"tan1"

"tomato"

> nearRcolor(col2rgb("tan2"), "Luv")


0.00
"tan2"

7.42

7.48

12.41

"tan1" "sandybrown"

13.69

"orange3"

> nearRcolor(col2rgb("tan2"), "Lab")


0.00
"tan2"

5.56

8.08

11.31

"tan1" "sandybrown"

> nearRcolor("#334455")
0.0867
"darkslategray"

"peru"

"orange2"

"coral"

> ## Now, consider choosing a color by looking in the


> ## neighborhood of one you know :
>
> plotCol(nearRcolor("deepskyblue", "rgb", dist=50))
Esperando para confirmar cambio de pgina...

> plotCol(nearRcolor("deepskyblue", dist=.1))


Esperando para confirmar cambio de pgina...

> install.packages("gstat")
Warning in install.packages("gstat") :
'lib = "C:/Program Files/R/R-3.2.1/library"' is not writable
--- Please select a CRAN mirror for use in this session --also installing the dependencies xts, intervals, sp, zoo, spacetime, FNN

probando la URL
'http://cran.revolutionanalytics.com/bin/windows/contrib/3.2/xts_0.9-7.zip'
Content type 'application/zip' length 662241 bytes (646 KB)
downloaded 646 KB

probando la URL
'http://cran.revolutionanalytics.com/bin/windows/contrib/3.2/intervals_0.15.0.zi
p'
Content type 'application/zip' length 653727 bytes (638 KB)
downloaded 638 KB

probando la URL
'http://cran.revolutionanalytics.com/bin/windows/contrib/3.2/sp_1.1-1.zip'
Content type 'application/zip' length 1519801 bytes (1.4 MB)
downloaded 1.4 MB

probando la URL
'http://cran.revolutionanalytics.com/bin/windows/contrib/3.2/zoo_1.7-12.zip'
Content type 'application/zip' length 897258 bytes (876 KB)
downloaded 876 KB

probando la URL
'http://cran.revolutionanalytics.com/bin/windows/contrib/3.2/spacetime_1.14.zip'
Content type 'application/zip' length 2980087 bytes (2.8 MB)
downloaded 2.8 MB

probando la URL
'http://cran.revolutionanalytics.com/bin/windows/contrib/3.2/FNN_1.1.zip'
Content type 'application/zip' length 532847 bytes (520 KB)
downloaded 520 KB

probando la URL
'http://cran.revolutionanalytics.com/bin/windows/contrib/3.2/gstat_1.0-25.zip'
Content type 'application/zip' length 2784947 bytes (2.7 MB)
downloaded 2.7 MB

package xts successfully unpacked and MD5 sums checked


package intervals successfully unpacked and MD5 sums checked
package sp successfully unpacked and MD5 sums checked
package zoo successfully unpacked and MD5 sums checked
package spacetime successfully unpacked and MD5 sums checked
package FNN successfully unpacked and MD5 sums checked
package gstat successfully unpacked and MD5 sums checked

The downloaded binary packages are in


C:\Users\Isela\AppData\Local\Temp\RtmpMNf0b5\downloaded_packages
> q()

>
> demo(gstat)
Error in demo(gstat) : No demo found for topic gstat
> demo(gstat)
Error in demo(gstat) : No demo found for topic gstat
> library (gstat)
Warning message:
package gstat was built under R version 3.2.2
> demo()
> demo(examples)

demo(examples)
---- ~~~~~~~~

Type <Return> to start :

> # $Id: examples.R,v 1.6 2006-02-10 19:05:02 edzer Exp $


> ## ex01.cmd, ex02.cmd:
> ##
> ## Two variables with (initial estimates of) variograms,
> ## calcute sample variogram and plot fitted model
> ##
>
> library(sp)

> par(ask = TRUE)

> data(meuse)

> coordinates(meuse)=~x+y

> x <- variogram(zinc ~ 1, meuse)

> v <- vgm(140000, "Sph", 800, nug = 10000)

> plot(x, model = v)


Esperando para confirmar cambio de pgina...

> plot(x, model = fit.variogram(x, model = v))


Esperando para confirmar cambio de pgina...

> x <- variogram(log(zinc) ~ 1, meuse)

> v <- vgm(.5, "Sph", 800, nug = .1)

> plot(x, model = v)


Esperando para confirmar cambio de pgina...

> plot(x, model = fit.variogram(x, model = v))


Esperando para confirmar cambio de pgina...

> ##
> ## ex03.cmd:
> ## Inverse distance interpolation on a mask map
> ##
> data(meuse.grid)

> gridded(meuse.grid) = ~x+y

> x <- krige(zinc ~ 1, meuse, meuse.grid, model = NULL)


[inverse distance weighted interpolation]

> library(lattice)

> spplot(x[1])
Esperando para confirmar cambio de pgina...

> ##
> ## ex04.cmd
> ## Local ordinary block kriging at non-gridded locations
> ##
> ## the gstat "classic" radius maps into the gstat "S" maxdist argument
> ##
> new.locs <- SpatialPoints(cbind(x = c(181170, 180310, 180205, 178673,
178770, 178270),
+

y = c(333250, 332189, 331707, 330066, 330675, 331075)))

> krige(zinc ~ 1, meuse, new.locs,


+

model = vgm(1.34e5, "Sph", 800, nug = 2.42e4),

block = c(40,40), nmax = 40, nmin = 20,

maxdist = 1000)

[using ordinary kriging]


coordinates var1.pred var1.var
1 (181170, 333250) 268.7576 19447.67
2 (180310, 332189) 663.4915 16991.33
3 (180205, 331707) 251.4606 21579.71
4 (178673, 330066) 532.5776 73807.91
5 (178770, 330675) 664.4039 23589.17
6 (178270, 331075) 647.6618 175360.21

> ##
> ## ex05.cmd
> ##
> ## Local simple point kriging on a mask map
> ##
> v <- vgm(0.581, "Sph", 900, nug = 0.0554)

> x <- krige(log(zinc) ~ 1, meuse, meuse.grid, model = v,


+

nmax = 40, nmin = 20, maxdist = 1000, beta = 5.9)

[using simple kriging]

> spplot(x[1], main = "log(zinc) simple kriging prediction")


Esperando para confirmar cambio de pgina...

> x$se = sqrt(x$var1.var)

> spplot(x["se"], main = "log(zinc) simple kriging standard errors")


Esperando para confirmar cambio de pgina...

> ##
> ## ex06.cmd
> ##
> ## Unconditional Gaussian simulation on a mask
> ## (local neigbourhoods, simple kriging)
> ##
> x <- krige(log(zinc) ~ 1, locations = NULL, newdata = meuse.grid,
+

model = v, nmax = 20, beta = c(5.9), nsim = 5, dummy = TRUE)

[using unconditional Gaussian simulation]

> spplot(x, main = "five unconditional realisations of a correlated Gaussian


field")
Esperando para confirmar cambio de pgina...

> ##
> ## ex07.cmd
> ##
> ## Gaussian simulation, conditional upon data
> ## (local neighbourhoods, simple and ordinary kriging)
> ##
> x <- krige(log(zinc) ~ 1, meuse, meuse.grid,
+

model = v, nmax = 20, beta = c(5.9), nsim = 5)

[using conditional Gaussian simulation]

> spplot(x, main = "five conditional realisations of a correlated Gaussian field")


Esperando para confirmar cambio de pgina...

> ##
> ## ex08.cmd
> ##
> ## Change of support: local ordinary block kriging on a mask
> ##
> x <- krige(log(zinc) ~ 1, meuse, meuse.grid,
+

model = v, nmax = 40, nmin = 20, maxdist = 1000,

block = c(40,40))

[using ordinary kriging]

> spplot(x[1], main = "ordinary block kriging predictions")


Esperando para confirmar cambio de pgina...

> x$se = sqrt(x$var1.var)

> spplot(x["se"], main = "ordinary block kriging prediction standard errors")


Esperando para confirmar cambio de pgina...

> ##
> ## ex09.cmd
> ##
> ## Obtain map values at data() locations
> ## (Point-map overlay)
> ##
> # we trick here by using inv.weighted distance interpolation, using the
> # single nearest observation. It will not fail on points outside the grid.
> # Note that we reversed meuse.grid and meuse to get these results.
> x <- krige(part.a ~ 1, meuse.grid, meuse, model = NULL, nmax = 1)
[inverse distance weighted interpolation]

> meuse$part.a = x$var1.pred

> x <- krige(part.b ~ 1, meuse.grid, meuse, model = NULL, nmax = 1)


[inverse distance weighted interpolation]

> meuse$part.b = x$var1.pred

> ##
> ## ex10.cmd
> ##
> ## Multiple kriging: prediction on more than one variable
> ## (ordinary kriging of two variables)
> ## (note that zinc_map.eas wass obtained through ex09.gst)

> ##
> x <- variogram(dist~1,meuse)

> v.dist <- fit.variogram(x, model = vgm(1,"Gau",100))

> plot(x, model = v.dist)


Esperando para confirmar cambio de pgina...

> g <- gstat(id = "ln.zinc", form = log(zinc) ~ 1,


+

data = meuse, nmax = 40, nmin = 20, maxdist = 1000, model = v)

> g <- gstat(g, id = "dist", form = dist ~ 1,


+

data = meuse, nmax = 40, nmin = 20, maxdist = 1000,

model = vgm(.01, "Nug", 0, add.to = v.dist))

> # the added nugget variance is necessary to avoid near-singular covariances


> x <- predict(g, meuse.grid)
[using ordinary kriging]

> spplot(x["ln.zinc.pred"], main = "log(zinc) ordinary kriging predictions")


Esperando para confirmar cambio de pgina...

> x$ln.zinc.se = sqrt(x$ln.zinc.var)

> spplot(x["ln.zinc.se"], main = "log(zinc) ordinary kriging prediction standard


errors")
Esperando para confirmar cambio de pgina...

> spplot(x["dist.pred"], main = "dist ordinary kriging predictions")


Esperando para confirmar cambio de pgina...

> x$dist.se = sqrt(x$dist.var)

> spplot(x["dist.se"], main = "dist ordinary kriging prediction standard errors")


Esperando para confirmar cambio de pgina...

> ##
> ## ex11.cmd
> ##
> ## Multivariable kriging: ordinary local cokriging of two variables
> ## For examples of fitting an LMC: see demo(cokriging)
> ##
> g <- gstat(id = "ln.zinc", form = log(zinc) ~ 1,
+

data = meuse, nmax = 40, nmin = 20, maxdist = 1000,

model = vgm(0.581, "Sph", 900, 0.0554))

> g <- gstat(g, id = "sq.dist", form = sqrt(dist) ~ 1,


+

data = meuse, nmax = 40, nmin = 20, maxdist = 1000,

model = vgm(0.0631, "Sph", 900, 0.0001))

> g <- gstat(g, id = c("ln.zinc", "sq.dist"),


+

model = vgm(-0.156, "Sph", 900, 1e-5))

> # small nugget necessary to let gstat recognize LMC


> x <- predict(g, meuse.grid)
Linear Model of Coregionalization found. Good.
[using ordinary cokriging]

> spplot(x["ln.zinc.pred"], main = "log(zinc) ordinary cokriging predictions")


Esperando para confirmar cambio de pgina...

> x$ln.zinc.se = sqrt(x$ln.zinc.var)

> spplot(x["ln.zinc.se"], main = "log(zinc) ordinary cokriging prediction


standard errors")
Esperando para confirmar cambio de pgina...

> spplot(x["sq.dist.pred"], main = "dist ordinary cokriging predictions")


Esperando para confirmar cambio de pgina...

> x$sq.dist.se = sqrt(x$sq.dist.var)

> spplot(x["sq.dist.se"], main = "dist ordinary cokriging prediction standard


errors")
Esperando para confirmar cambio de pgina...

> ##
> ## ex12.cmd
> ##
> ## Stratified ordinary kriging (within-category ordinary kriging)
> ##
>
> # find out in which part the data are:
> meuse$part.a = krige(part.a~1, meuse.grid, meuse, nmax=1)$var1.pred
[inverse distance weighted interpolation]

> x1 = krige(log(zinc)~1, meuse[meuse$part.a == 0,],


+
meuse.grid[meuse.grid$part.a == 0,], model = vgm(.548, "Sph", 900, .
0654),
+

nmin = 20, nmax = 40, maxdist = 1000)

[using ordinary kriging]

> x2 = krige(log(zinc)~1, meuse[meuse$part.a == 1,],


+

meuse.grid[meuse.grid$part.a == 1,], model = vgm(.716, "Sph", 900),

nmin = 20, nmax = 40, maxdist = 1000)

[using ordinary kriging]

> x = rbind(as.data.frame(x1), as.data.frame(x2))

> gridded(x) = ~x+y

> spplot(x["var1.pred"], main = "stratified kriging predictions")


Esperando para confirmar cambio de pgina...

> ##
> ## ex13.cmd
> ##
> ## Local universal kriging, using one continuous variable
> ###
> ## the variogram should be that of the residual:
> x <- krige(log(zinc) ~ sqrt(dist), meuse, meuse.grid,
+

model = vgm(.149, "Sph", 700, .0674),

nmax = 40, nmin = 20, maxdist = 1000)

[using universal kriging]

> spplot(x["var1.pred"], main = "universal kriging predictions")


Esperando para confirmar cambio de pgina...

> x$var1.se = sqrt(x$var1.var)

> spplot(x["var1.se"], main = "universal kriging prediction standard errors")

Esperando para confirmar cambio de pgina...

> ##
> ## ex14.cmd
> ##
> ## Universal kriging, using one continuous and
> ## two binary variables.
> ##
> x <- krige(log(zinc) ~ -1 + sqrt(dist)+ part.a + part.b,
+

meuse, meuse.grid, model = vgm(.149, "Sph", 700, .0674))

[using universal kriging]

> spplot(meuse.grid["part.a"], main = "the areas defining part.a (1) and part.b
(0)")
Esperando para confirmar cambio de pgina...

> spplot(x["var1.pred"], main = "universal kriging predictions")


Esperando para confirmar cambio de pgina...

> x$var1.se = sqrt(x$var1.var)

> spplot(x["var1.se"], main = "universal kriging prediction standard errors")


Esperando para confirmar cambio de pgina...

> ##
> ## ex14a.cmd
> ##
> ## stratified universal kriging:
> ## (again: not implemented)
> ##

>
> ## ex15.cmd
> ##
> ## Local linear model, using one continuous variable
> ##
> x <- krige(log(zinc) ~ sqrt(dist), meuse, meuse.grid,
+

model = NULL, nmax = 40, nmin = 20, maxdist = 1000)

[ordinary or weighted least squares prediction]

> spplot(x["var1.pred"], main = "IID local linear model kriging predictions")


Esperando para confirmar cambio de pgina...

> x$var1.se = sqrt(x$var1.var)

> spplot(x["var1.se"], main = "IID local linear model prediction standard


errors")
Esperando para confirmar cambio de pgina...

> ##
> ## ex16.cmd
> ##
> ## Multivariable indicator cosimulation
> ## ==>> see demo(cosimulation) for an extended example how to do this
> ##
>
> ##
> ## ex17.cmd
> ##
> ## global coordinate polynomial trend surfaces
> ## trend orders 0-3 ==>> better use lm() for this

> ##
Warning message:
package sp was built under R version 3.2.2
> x<-c(1,2,3,4,5,6,7,8,9,10)
> x$
+
+
+
+
+c
Error in x$c : $ operator is invalid for atomic vectors
> x^2
[1] 1 4 9 16 25 36 49 64 81 100
> x<-seq(0,4,0.1)
>x
[1] 0.0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0 1.1 1.2 1.3 1.4 1.5 1.6 1.7 1.8
[20] 1.9 2.0 2.1 2.2 2.3 2.4 2.5 2.6 2.7 2.8 2.9 3.0 3.1 3.2 3.3 3.4 3.5 3.6 3.7
[39] 3.8 3.9 4.0
> mean(x)
[1] 2
> plot(x,x^2,type="l")
> plot(x,x^2,type="p")
> plot(x,x^2,type="l"
+c
Error: unexpected symbol in:
"plot(x,x^2,type="l"
c"
> plot(x,x^2,type="l")
> plot(x,x^2)
> plot(x,x^2,type="l",col="blue")

> x=rnom(30)
Error: no se pudo encontrar la funcin "rnom"
> x=rnorm (30)
> p<-rnorm (30)
>p
[1] -0.891861978 -0.122828218 0.877440176 1.267248900 0.627286959
[6] -0.378100966 0.858271393 0.303717256 -0.565343522 -1.928233269
[11] 0.746375452 -0.206070941 -0.010140040 -0.473720599 -2.022354366
[16] 0.216574821 -0.601776872 0.002840592 -0.442315720 -1.672318091
[21] -1.050505918 0.375925133 -0.394971374 0.281650376 -1.589366158
[26] 0.182030517 1.888707124 2.660406643 -0.911409240 -0.576548984
> plot(x,x^2,type="l",col="blue")
> hist(p)
> e<-rnorm(30)
> plot(p)
> plot(e,p,type="l")
> p+e
[1] -0.85103940 1.40573141 1.11172503 0.54711536 0.81270268
-0.66928198
[7] 0.84658020 0.46128848 0.53052053 -1.79054859 0.83191301
-0.90060065
[13] 0.63033389 -1.63290437 -1.10382111 1.87431871 0.46317276
0.65025830
[19] -0.20072392 -1.43168431 -0.63078173 0.00272631 -1.32219185
-0.13892253
[25] -2.53684916 -0.59669804 0.66247343 3.19140369 -0.71840342
-0.49216694
> a=p,e
Error: inesperado ',' in "a=p,"
> r<-(p,e)
Error: inesperado ',' in "r<-(p,"
> p,e

Error: inesperado ',' in "p,"


> boxplot(p)