as.Grid: Coercion to 'Grid'

View source: R/GridData.R

as.GridR Documentation

Coercion to Grid

Description

Coercion to Grid.

Usage

as.Grid(object, ...)

## Default S3 method:
as.Grid(object, ...)

## S3 method for class 'matrix'
as.Grid(object, ...)

## S3 method for class 'numeric'
as.Grid(object, ...)

## S3 method for class 'data.frame'
as.Grid(object, ...)

## S3 method for class 'list'
as.Grid(object, ...)

Arguments

object

An object to be coerced into a Grid object.

...

Not used yet.

Details

The dimensions of the Grid object are matched to the d columns of the object given in object, in the same order. Each column is coerced into a factor. Each combination of the d different levels must be found exactly one in the data frame or matrix, and the the row number of that combination is stored in the index slot of the object.

Value

Object with S4 class "Grid".

Note

A numeric object is coerced into a Grid object with dimension d =1.

Examples

set.seed(1234)
GDnum <- as.Grid(runif(8))
GDlist <- as.Grid(list("X" = runif(8), "Y" = runif(4)))
df <- expand.grid(X = runif(6), Y = runif(4))
GDdf <- as.Grid(df)
GDmat <- as.Grid(as.matrix(df))

IRSN/smint documentation built on Dec. 9, 2023, 9:53 p.m.