AttributeList-class {sp} | R Documentation |
Attribute list; a kind of data.frame but without row.names
Objects can be created by calls of the form AttributeList(x)
,
with x
a list having elements of equal length.
att
:"list"
, containing the
attributes variables. The variables are guaranteed to have equal
length, and can be of any type that has a length signature(x = "AttributeList")
: subsets signature(from = "AttributeList", to = "data.frame")
: convert the list
slot to data.frame signature(from = "AttributeList", to = "list")
: retrieve the list slot signature(from = "data.frame", to = "AttributeList")
: ... signature(from = "list", to = "AttributeList")
: ... dim(x)[1]
is the length of variables (nr or rows),
dim(x)[2]
the number of variables (nr of columns) summary.data.frame
on the listIn 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.
Edzer J. Pebesma, e.pebesma@geo.uu.nl
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