[R-sig-Geo] kriging output
Edzer Pebesma
edzer.pebesma at uni-muenster.de
Mon May 5 22:08:18 CEST 2008
Dave Depew wrote:
> Thanks,
> This worked.
>
> I'm still confused why the if else statement didn't work...
> If one wanted to do conditional arithmetic would a for statement bee
> needed?
>
>
> e.g.
> meuse.grid[["class"]] = for(i in 1:length(meuse.grid[["dist"]])){
> if (meuse.grid[["dist"]]<0.5)
> {meuse.grid[["class"]]=10*meuse.grid[["dist]]} else
> {meuse.grid[["class"]]=100* meuse.grid[["dist"]]}
> }
>
I'd say
meuse.grid$class = ifelse(meuse.grid$dist < .5, 10, 100) * meuse.grid$dist
assigning the result from a for statement also does not yield a beauty
price if you ask me, but that might be my backgrounds in C, long ago.
--
Edzer
More information about the R-sig-Geo
mailing list