'R approxfun() returns "error in xy.coords: object 'y' not found"

I tried to follow the second example from ?approxfun, but I have an error right from the start and can't seem to find anything related to this...

When I run f <- approxfun(x,y), it gives me the following error:

Error in xy.coords(x, y, setLab = FALSE) : object 'y' not found

I'm not even telling approxfun to do anything as I'm simply trying to define the function f, so why is this happening?

I've restarted Rstudio and the problem still persists. I'm running R version 4.0.2 on Windows 10, and currently have the following base packages attached (from sessionInfo()): stats graphics grDevice utils datasets methods base Is it possible any of these packages are somehow messing up approxfun?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source