Hey Houston, I have still a problem!!
Why when I use ggplot_smooth, my lm is correct see
(filtered_split_groups <- group_split(group_by(filtered_df, cutvel)))
(top2_of_each_as_list <- purrr::map(
filtered_split_groups,
~ top_n(., 2, wt = Acceleration)
))
(top2_as_one_df <- bind_rows(top2_of_each_as_list))
p = ggplot() +
geom_point(data = data_final, aes(x = data_final$Velocity, y = data_final$Acceleration)) +
geom_point(data = top2_as_one_df, aes(x = top2_as_one_df$Velocity, y = top2_as_one_df$Acceleration), color = "red") +
geom_smooth(mapping = aes (x = top2_as_one_df$Velocity, y = top2_as_one_df$Acceleration), data = top2_as_one_df, color = "Red", method = "lm", fill="Red",formula = y ~ x) +
plot(p)
And when I'm trying to use directly the lm function, it is not correct...
plot(data_final,xlim=c(0,10),ylim=c(0,10),
main="AS profile practice",
xlab="Velocity (m/s)",
ylab="Acceleration (m/s²)")
abline(lm1, col="red",lxd=2)
@nirgrahamuk Have you got a thought on it?
Thanks