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

return doubleis not valid R code. (If you're just indicating that your function returns somenumeric, that's fine ... just do that. Having intentionally-invalid or incomplete R code makes it difficult to narrow down where you are having difficulty.)ysis amatrixwith 171 rows and columns ... how do those values correlate withdf's 171 rows? What is the purpose ofdf? Are you hoping to generate a heatmap fromys?r ggplot2 heatmapmight also be helpful to see various options.)