[R] Odp: Understanding how R works
Petr PIKAL
petr.pikal at precheza.cz
Wed Jul 28 12:11:57 CEST 2010
Hi
r-help-bounces at r-project.org napsal dne 28.07.2010 10:08:37:
> Hello everyone.
> I am more than new into R.
> Today I have started reading about grf function that is included in
geoR
> package.
>
> According the manual (vignette?)
>
>
> grf() generates (unconditional) simulations of Gaussian random fields
for given
> covariance parameters. geoR2RF converts model specification used by geoR
to the
> correponding one in RandomFields.
>
> I would like to use this function to fill in with valies a rasterlayer.
>
> According to the manual grf() returns a list
>
> Value
> grf returns a list with the components:
> coords an n x 2 matrix with the coordinates of the simulated data.
> data a vector (if nsim = 1) or a matrix with the simulated values.
For the
> latter each column corresponds to one simulation.
>
> cov.model a string with the name of the correlation function.
> nugget the value of the nugget parameter.
> cov.pars a vector with the values of sigma^2 and phi, respectively.
> kappa value of the parameter kappa.
> lambda value of the Box-Cox transformation parameter lambda.
> aniso.pars a vector with values of the anisotropy parameters, if
provided in
> the function call.
>
> method a string with the name of the simulation method used.
> sim.dim a string "1d" or "2d" indicating the spatial dimension of
the
> simulation.
> .Random.seed the random seed by the time the function was called.
> messages messages produced by the function describing the
simulation.
> call the function call.
> geoR2grf returns a list with the components:
> model RandomFields name of the correlation model
> param RandomFields parameter vector
>
>
> And this is exactly the point I do not get.
> In the example section of the same function I can find the following:
>
> sim1 <- grf(100, cov.pars = c(1, .25))
> # a display of simulated locations and values
> points(sim1)
>
> How the function points() understand what to read exactly from the list?
You can track R functions sometimes by typing name of function or look if
there are methods for some object
e.g.
> methods(points)
[1] points.default points.formula* points.table*
Non-visible functions are asterisked
> points.default
function (x, y = NULL, type = "p", ...)
plot.xy(xy.coords(x, y), type = type, ...)
<environment: namespace:graphics>
> xy.coords
function (x, y = NULL, xlab = NULL, ylab = NULL, log = NULL,
recycle = FALSE)
{
if (is.null(y)) {
ylab <- xlab
if (is.language(x)) {
if (inherits(x, "formula") && length(x) == 3) {
ylab <- deparse(x[[2L]])
xlab <- deparse(x[[3L]])
y <- eval(x[[2L]], environment(x), parent.frame())
x <- eval(x[[3L]], environment(x), parent.frame())
}
else stop("invalid first argument")
}
else if (inherits(x, "ts")) {
y <- if (is.matrix(x))
x[, 1]
else x
x <- stats::time(x)
xlab <- "Time"
}
else if (is.complex(x)) {
y <- Im(x)
x <- Re(x)
xlab <- paste("Re(", ylab, ")", sep = "")
ylab <- paste("Im(", ylab, ")", sep = "")
}
....
So you could check if there is points method for grf object
Regards
Petr
>
> I would like tot hank you in advance for your replies
> Best Regards
> Alex
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
More information about the R-help
mailing list