Skip to content
Prev 10900 / 29559 Next

Help on extract function

On 02/12/2011 02:05 PM, Sean O'Riordain wrote:
You can, if you avoid modifying object slots directly, but use the
appropriate methods. So to select the first ten polygons with their
attributes you should NEVER do something like:

polygon at data = polygon at data[1:10,] # NO!

but rather

polygonSel = polygon[1:10,]

For addressing or adding columns you can also use

polygon$existingcolumn
polygon[["existingcolumn"]]

and assigning:

polygon$newcolum  <- 1:nrow(polygon at data)

which will have the same effect as

polygon at data$newcolumn <- 1:nrow(polygon at data)

... whatever you prefer!
--
Edzer