On Fri, 13 Aug 2010, Patrick Giraudoux wrote:


Hi,

I am trying to subset a SpatialGridDataFrame object as following:

idx<-chinatemput...@data[,1]>10 # select elements of column1 whose values are > 10 idx[is.na(idx)]<-FALSE # make a vector of class "logical" (replacing NA by FALSE)

and this gives:

ChinaTempUTM47[idx,]
Error in ChinaTempUTM47[idx, ] : (subscript) logical subscript too long

However,

length(idx)
[1] 13536
nrow(chinatemput...@data)
[1] 13536


This was discussed in:

https://stat.ethz.ch/pipermail/r-sig-geo/2010-August/008973.html

Use one of the solutions suggested there, and note that the "[" method for SpatialGridDataFrame takes [ row, col, band, ...], like an array but not like a data.frame; see ?"SpatialGridDataFrame-class". You could also coerce to SpatialPixelsDataFrame, which then behaves like a data.frame, not an array.

Hope this helps,

Roger


So, I canot sort out what happens.

Any hint welcome

Patrick

_______________________________________________
R-sig-Geo mailing list
R-sig-Geo@stat.math.ethz.ch
https://stat.ethz.ch/mailman/listinfo/r-sig-geo


--
Roger Bivand
Economic Geography Section, Department of Economics, Norwegian School of
Economics and Business Administration, Helleveien 30, N-5045 Bergen,
Norway. voice: +47 55 95 93 55; fax +47 55 95 95 43
e-mail: roger.biv...@nhh.no

_______________________________________________
R-sig-Geo mailing list
R-sig-Geo@stat.math.ethz.ch
https://stat.ethz.ch/mailman/listinfo/r-sig-geo

Reply via email to