[R] Two dimensional Array defined on intevals

Jonathan P Daily jdaily at usgs.gov
Mon Nov 29 17:56:44 CET 2010


Does this work for you?

g <- function(x,y) ifelse(x < .5, 0, 2) + ifelse(y < .5, 1, 2)

--------------------------------------
Jonathan P. Daily
Technician - USGS Leetown Science Center
11649 Leetown Road
Kearneysville WV, 25430
(304) 724-4480
"Is the room still a room when its empty? Does the room,
 the thing itself have purpose? Or do we, what's the word... imbue it."
     - Jubal Early, Firefly

r-help-bounces at r-project.org wrote on 11/29/2010 11:37:41 AM:

> [image removed] 
> 
> [R] Two dimensional Array defined on intevals
> 
> Leon Adams 
> 
> to:
> 
> r-help
> 
> 11/29/2010 11:39 AM
> 
> Sent by:
> 
> r-help-bounces at r-project.org
> 
> Hi I am new to R and am trying to set up a two-dimensional array/matrix 
with
> the elements defined by the function similar to below. Been trying to 
use
> outer with apply but can't seem to get the indexing quite right. Is 
their a
> simple way of accomplishing this task ??
> 
>                       -----
>                     /
>                    |     1  x < 0.5 & y < 0.5
>                    |
>                   /      2  x < 0.5 & y > 0.5
>                 /
> G(x,y) =   \
>                  \
>                  |       3  x > 0.5 & y < 0.5
>                  |
>                  \       4  x > 0.5 & y > 0.5
>                    -----
> -- 
> Thanks in advance
> Leon Adams
> 
>    [[alternative HTML version deleted]]
> 
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide 
http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.



More information about the R-help mailing list