Home > Enterprise >  Retrieving the list of y values in a function
Retrieving the list of y values in a function

Time:10-10

I have a linear equation y=2x 1 and want to plot this with an x limit of 0 to 20. For this I have done curve(2x 1,from=0,to=20,xlab="x",ylab="y"). Now what I want is to extract a list of the responses (y values); so a list of 1,3,5...,41. Is there a way to do this?

CodePudding user response:

You do not need to extract it. You an simply compute it with a vector 0:20 and R will do the rest.

2 * (0:20)   1
#>  [1]  1  3  5  7  9 11 13 15 17 19 21 23 25 27 29 31 33 35 37 39 41

Created on 2021-10-09 by the reprex package (v2.0.1)

  •  Tags:  
  • r
  • Related