I have a function :
f <- function(x,y){ return (x + y)}
I have to make a plot 2 D (not 3 D) with on the X and Y aes c(30:200). So I have to map both the x and the y to the function and based on the result of that function I have to color the point f(xi,yi) > ? and so on. How would I achieve this ?
I tried :
range <- c(30:200)
ys = matrix(nrow = 171,ncol = 171 )
for (i in range){
for (y in range){
ys[i-29,y-29] <- f(i,y) # exemple if f(i,j) < 0.5 color (i,j) red
}
}
df <- data.frame(x= c(30:200), y= c(30:200))
Now the x and y axes are correct however how would I be able to plot this since I cant just bind ys to the y axes. Using a ys seems like it isnt the right way to achieve this, how would I do this
Thx for the help