[R-sig-Geo] spacetime: remove NAs from STSDF object

Edzer Pebesma edzer.pebesma at uni-muenster.de
Tue Aug 23 15:59:58 CEST 2011



On 08/22/2011 05:49 PM, Christian Kamenik wrote:
> Dear all,
> 
> I have observations in space and time with quite a lot of missing values
> that I want to arrange in a space-time sparse data-frame object (STSDF
> from package 'spacetime'). For simplicity, I first created a
> spatio-temporal full grid data frame (which I call my.STFDF) that
> included all the missing observations. Then I did the following:
> 
> my.STSDF <- as(my.STFDF, "STSDF")

Christian,

this single line should do, as the coercion does exactly that --
removing all the missing valued S/T combinations. If it doesn't, please
report.

Best regards,

> slot(my.STSDF,'index') <-
> matrix(slot(my.STSDF,'index')[complete.cases(slot(my.STSDF,'data'))],ncol=2)
> 
> slot(my.STSDF,'data') <-
> slot(my.STSDF,'data')[complete.cases(slot(my.STSDF,'data')),]
> 
> This is the first time I try the spacetime package, and I was wondering
> if the code above would be an appropriate way of dealing with STFDF and
> STSDF objects.
> 
> Many thanks in advance, Christian
> 
> -
> 
> -----------------------------------------------
> Oeschger Centre for Climate Change Research, Institute of Geography& 
> Institute of Plant Sciences
> University of Bern
> 
> http://www.stomatocysts.unibe.ch/kamenik
> mailto: christian.kamenik at giub.unibe.ch
> 
> Postal address:
> Dr. Christian Kamenik
> Institute of Geography
> Erlachstrasse 9a, Trakt 3
> 3012 Bern, Switzerland
> 
> Tel. +41 (0)31 631 5091
> Fax +41 (0)31 631 43 38
> 
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo at r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo

-- 
Edzer Pebesma
Institute for Geoinformatics (ifgi), University of Münster
Weseler Straße 253, 48151 Münster, Germany. Phone: +49 251
8333081, Fax: +49 251 8339763  http://ifgi.uni-muenster.de
http://www.52north.org/geostatistics      e.pebesma at wwu.de



More information about the R-sig-Geo mailing list