0

I have a dataset called dataframe (a 2d table) and a best fit curve as:

scatter.smooth(dataframe, xlab="", ylab="") 

What code would I need to realize and evaluate (get numerical value of) a Y value on that best fit curve at a single x value?

1 Answers1

2

Try

set.seed(1)
dataframe <- data.frame(x=runif(100), y=runif(100))
scatter.smooth(dataframe, xlab="", ylab="") 
res <- with(dataframe, loess.smooth(x, y, evaluation = 200))
lengths(res)
#   x   y 
# 200 200 

x <- 0.5
y <- res$y[res$x>=x][1]
points(x, y, col="blue", pch = 19, cex=2)

enter image description here

lukeA
  • 53,097
  • 5
  • 97
  • 100