r - lapply and interp (akima) -
i'd interpolate on many individual data.frames
stored within list
using akima
package.
having split original data frame:
store <- split(data, data$frameid)
i tried this...
results <- lapply(store, interp, x = lon, y = lat, z = precip)
but error message error in interp(x = lon, y = lat, z = precip) : object 'lat' not found
.
single results can successfully generated following..
results <-list() # create , empty list results results[[i]]<-with(store$`600`, interp(x = lon, y = lat, z = precip)).
where 600
represents name of 1 of data.frames
within list.
however attempting generalise entire list using loop-approach..
i=1 (i in i:length(store)){ results[[i]]<-with(store$`i`, interp(x = lon, y = lat, z = precip)) }
i again receive error in interp(x = lon, y = lat, z = precip) : object 'lat' not found
.
any advice appreciated.
using suggestions, , accounting duplicate points (same lat , lon stations) job.
i=1 (i in i:length(store)){ results[[i]]<-with(store[[i]], interp(x = lon, y = lat, z = precip, duplicate = "mean")) }
Comments
Post a Comment