I want to get a dataframe containing n numbers of xy-coordinates that describe a linear function between two points P1(x1, y1) and P2(x2, y2) .
My approach would be to find the xy-coordinates of two points and calculate the slope and intercept of this linear equation y = slope * x + intercept
.
For simplicity let: P
x1 = 0.1
y1 = 0.2
x2 = 1.1
y2 = 0.6
n = c(1:200) #example length of my data
slope = (y2 - y1) / (x2 - x1)
intercept = y1 - slope * x1
So far so good, but now i would like to compute the individual xy-coordinates of my linear equation into a dataframe baseline
with length(n)
rows with the columns x_baseline
and y_baseline
.
How would one go about solving this problem? So far, I could not find an satisfactory answer online, any help is highly appreciated!
For clarification a drawing of my desired output here