Hi, thank you very much. But actually that is not exactly what I want to do. I want to select a specific time range and spatial points and manipulate the corresponding data. When I subset the dataframe I must do the selection manually and that is not that nice.
Any idea how I could do this? Cheers, Martin ________________________________________ From: Aman Verma [aman.ve...@mcgill.ca] Sent: Friday, March 11, 2011 7:16 PM To: Roth, M.; r-sig-geo@r-project.org Subject: RE: replace values in spacetime (STFDF) object Hi Martin, You put the brackets in the wrong place. You want to subset the dataframe, right, not the stfdf object, so: stfdf@data$values[1] <- stfdf@data$values[1] + 1 would increase the "value" in the first row of the stfdf@data data frame. stfdf@data[,1] would get you the first column of the data frame. If you wanted to increase the whole column by one: stfdf@data[,1] = stfdf@data[,1] + 1 aman -----Original Message----- From: r-sig-geo-boun...@r-project.org [mailto:r-sig-geo-boun...@r-project.org] On Behalf Of Roth, M. Sent: March 11, 2011 10:00 AM To: r-sig-geo@r-project.org Subject: [R-sig-Geo] replace values in spacetime (STFDF) object Hello, I want to replace specific values in a STFDF object from the spacetime package. As example consider the following stfdf object out of the vignette. sp = cbind(x = c(0,0,1), y = c(0,1,1)) row.names(sp) = paste("point", 1:nrow(sp), sep="") sp = SpatialPoints(sp) time = xts(1:4, as.POSIXct("2010-08-05", tz = "GMT")+3600*(10:13)) m = c(10,20,30) # means for each of the 3 point locations mydata = rnorm(length(sp)*length(time),mean=rep(m, 4)) IDs = paste("ID",1:length(mydata), sep = "_") mydata = data.frame(values = signif(mydata,3), ID=IDs) stfdf = STFDF(sp, time, mydata) Now I want to do something like this: stfdf[ , 1]@data$values <- stfdf[ , 1]@data$values + 1 I get the following error: Error in stfdf[, 1]@data$values <- stfdf[, 1]@data$values + 1 : object of type 'S4' is not subsettable Does anybody know how to do that in a correct way? Thanks a lot, Martin Roth _______________________________________________ R-sig-Geo mailing list R-sig-Geo@r-project.org https://stat.ethz.ch/mailman/listinfo/r-sig-geo _______________________________________________ R-sig-Geo mailing list R-sig-Geo@r-project.org https://stat.ethz.ch/mailman/listinfo/r-sig-geo