AttributeList-class {sp} | R Documentation

## Class "AttributeList"

### Description

Attribute list; a kind of data.frame but without row.names

### Objects from the Class

Objects can be created by calls of the form `AttributeList(x)`, with `x` a list having elements of equal length.

### Slots

`att`:
  Object of class `"list"`, containing the attributes variables. The variables are guaranteed to have equal length, and can be of any type that has a length

### Methods

[
  `signature(x = "AttributeList")`: subsets
coerce
  `signature(from = "AttributeList", to = "data.frame")`: convert the list slot to data.frame
coerce
  `signature(from = "AttributeList", to = "list")`: retrieve the list slot
coerce
  `signature(from = "data.frame", to = "AttributeList")`: ...
coerce
  `signature(from = "list", to = "AttributeList")`: ...
as.list
  coerce AttributeList object to list
as.data.frame
  coerce AttributeList object to data.frame
dim
  retrieve dimensions of object, as if it were a data.frame: `dim(x)[1]` is the length of variables (nr or rows), `dim(x)[2]` the number of variables (nr of columns)
[[, $
  retrieve a list element
[[<-, $<-
  assign a list element
summary
  calls `summary.data.frame` on the list
names
  get names from the list
names<-
  assign names to the list

### Note

In earlier versions (sp <= 0.7-6), objects of class SpatialPointsDataFrame-class, SpatialPixelsDataFrame-class and SpatialGridDataFrame-class had a slot of class data.frame to store the attribute information. It turns out that especially for larger grids, holding the grid attribute information in a data.frame requires up to a factor 11 more memory than needed by the data alone, for the sole reason that R creates unique row.names for each row (i.e., value).

To get around this problem, we created the simple S4 AttributeList class which has a single slot which is a list, without row.names, but with a validator function that checks that all elements in the list have equal length. The class is meant to behave similar to a data.frame, having a similar set of methods. It does not automatically convert character data to factors.

If you have row.names in your data.frame, and you want to keep them when you convert them to e.g. a SpatialPointsDataFrame-class object using coordinates, you should first copy the row.names to a column in the data.frame. If not, they will get lost.

### Author(s)

Edzer J. Pebesma, e.pebesma@geo.uu.nl

### See Also

list, data.frame

### Examples

    x = AttributeList(list(a = 1:10, b = sample(1:10), c = runif(10)))
    x
    summary(x)
    x = object.size(AttributeList(list(a = 1:1000000)))
    y = object.size(data.frame(a = 1:1000000))
    y / x

[Package sp version 0.7-12 Index]