2

when using the "curve" function in R, how do you suppress/stop the plot from showing up? For example, this code always plots the curve

my_curve = curve(x)

Is there a parameter to do this or should I being using a different function? I just want the x y points as a dataframe from the curve.

Oliver Oliver
  • 2,057
  • 4
  • 16
  • 14

2 Answers2

3

curve() is from the graphics library and is unhandy for generating lists.

Just try using:

x = seq(from, to, length.out = n)
y = function(x)

If you stick to the curve function, the closest to a solution I know is adding dev.off() after the curve() statement!

tobiaspk1
  • 378
  • 1
  • 11
0

Here's a way to take advantage of the part of curve that you want without generating a plot.

I made a copy of the curve function (just type curve in the console); called it by a new name (curve2); and commented out the four lines at the end starting with if (isTRUE(add)). When it's called and assigned, I had a list with two vectors—x and y. No plot.

Edward Carney
  • 1,372
  • 9
  • 7