STIDF subsetting problem

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

STIDF subsetting problem

scizmeli
I am trying rearrange the rows of a STIDF object using  a numerical variable idx containing the row indexes having  some repeated indexes :

data(air)
rural = as(rural,"STIDF")
rural[c(1,1,1)]

gives me only a 1-row STIDF object. I would rather expect a 3-rows STIDF object, with the replicates of the 1st row.

The general behavior of R in such a case, however, would be to replicate the rows. I give below two examples with data.frame and list objects ;

a=data.frame(a=c(1,2,3,4),b=c(1,3,4,5))
a[c(1,1,1),]
or
a=list(k=1,l=2,m=3)
a[c(1,1,1)]

Is this behavior of spacetime (namely the internal function subs.STIDF) can be modified in the future to provide a more compatible with the R standards? In its current way, it is not possible to use the subsetting in a traditional R-fashion.
thanks
Servet
Reply | Threaded
Open this post in threaded view
|

Re: STIDF subsetting problem

edzer
I think this is a fair request, and changed the code accordingly. The
updated code is on r-forge; the next CRAN version will support this.

Also, this version has an stplot method for STIDF that shows attributes
per time (slice), e.g. point pattern marks, the same way spplot does for
multiple attributes.

Thanks for the suggestion,

On 06/15/2013 04:35 PM, scizmeli wrote:

> I am trying rearrange the rows of a STIDF object using  a numerical variable
> idx containing the row indexes having  some repeated indexes :
>
> data(air)
> rural = as(rural,"STIDF")
> rural[c(1,1,1)]
>
> gives me only a 1-row STIDF object. I would rather expect a 3-rows STIDF
> object, with the replicates of the 1st row.
>
> The general behavior of R in such a case, however, would be to replicate the
> rows. I give below two examples with data.frame and list objects ;
>
> a=data.frame(a=c(1,2,3,4),b=c(1,3,4,5))
> a[c(1,1,1),]
> or
> a=list(k=1,l=2,m=3)
> a[c(1,1,1)]
>
> Is this behavior of spacetime (namely the internal function subs.STIDF) can
> be modified in the future to provide a more compatible with the R standards?
> In its current way, it is not possible to use the subsetting in a
> traditional R-fashion.
> thanks
> Servet
>
>
>
> --
> View this message in context: http://r-sig-geo.2731867.n2.nabble.com/STIDF-subsetting-problem-tp7583785.html
> Sent from the R-sig-geo mailing list archive at Nabble.com.
>
> _______________________________________________
> R-sig-Geo mailing list
> [hidden email]
> 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
83 33081, Fax: +49 251 8339763 http://ifgi.uni-muenster.de

_______________________________________________
R-sig-Geo mailing list
[hidden email]
https://stat.ethz.ch/mailman/listinfo/r-sig-geo
Reply | Threaded
Open this post in threaded view
|

Re: STIDF subsetting problem

scizmeli
Thanks for your interest, and timely fix, Edzer.

Do you also think that some modifications can be done in the way STFDF and STSDF are subsetted? I understand that they are different than STIDF as length(rural@sp)!=nrow(rural@data)

Servet

Reply | Threaded
Open this post in threaded view
|

Re: STIDF subsetting problem

edzer
I don't know what you would like to modify:

> library(spacetime)
Loading required package: sp
> data(air)
> class(rural)
[1] "STFDF"
attr(,"package")
[1] "spacetime"
> dim(rural)
    space      time variables
       70      4383         1
> dim(rural[c(1,1:10),])
    space      time variables
       11      4383         1
> dim(rural[,c(1,1:10)])
    space      time variables
       70        11         1

please try this yourself; the behaviour is of course different, as we're
replicating a full location time series (first case) or time slice
(second case).

On 06/17/2013 12:15 PM, scizmeli wrote:

> Thanks for your interest, and timely fix, Edzer.
>
> Do you also think that some modifications can be done in the way STFDF and
> STSDF are subsetted? I understand that they are different than STIDF as
> length(rural@sp)!=nrow(rural@data)
>
> Servet
>
>
>
>
>
> --
> View this message in context: http://r-sig-geo.2731867.n2.nabble.com/STIDF-subsetting-problem-tp7583785p7583798.html
> Sent from the R-sig-geo mailing list archive at Nabble.com.
>
> _______________________________________________
> R-sig-Geo mailing list
> [hidden email]
> 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
83 33081, Fax: +49 251 8339763 http://ifgi.uni-muenster.de

_______________________________________________
R-sig-Geo mailing list
[hidden email]
https://stat.ethz.ch/mailman/listinfo/r-sig-geo