I have this df
tree sdepth shallow_avg ddepth deep_avg swdepth sw_avg
<dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
1 3 2 0.0857 3.5 0.0454 3.7 0
2 4 2 0.142 3.5 0.0991 4.1 0
3 5 2 0.0119 3.5 0.00498 5.7 0
4 7 2 0.0217 3.5 0.0169 5.1 0
I am trying to plot and curve fit each sarate tree. the (x,y) points are (0,0), (sdepth,shallow_avg), (ddepth,deep_average), and (swdepth,sw_avg)
my base code is
sample_data <- data.frame(x = c(0, 2, 3.5, 4.7), y = c(0, 0.0679, 0.0367, 0))
# fit polynomial regression models up to degree 5
linear_model5 <- lm(y~poly(x,5,raw=TRUE), data=sample_data)
# create a basic scatterplot
plot(sample_data$x, sample_data$y)
# define x-axis values
x_axis <- seq(1, 10, length=10)
# add curve of each model to plot
lines(x_axis, predict(linear_model5, data.frame(x=x_axis)), col='orange')
but that is only doing one tree and is by hand