In the above graph two vertical and horizontal line segments are drawn which will intersect the regression line. How to write code to draw those lines to find the intersecting point?

Apr 4, 2022 711 views

## 1 answer to this question.

To find the intersecting point use the following code:

```data <- data.frame(load = rep(c(0,4.4,10.7,17,21.4), each = 4),
VO2max= c(28.0,41.0,56.3,71.3,28.2,41.1,57.0,
75.0,31.0,45.4,63.6,82.1, 32.0,48.8,
66.8,85.5,34.6,50.5,69.9,89.3))

You can use ggplot2 to plot the intersecting points.

```ibrary(ggplot2)

geom_point(aes(shape = Gradient), size = 3) +
geom_abline(aes(slope = 0.31, intercept = 27.46)) +
geom_abline(aes(slope = 0.49, intercept = 40.18)) +
geom_abline(aes(slope = 0.67, intercept = 55.54)) +
geom_abline(aes(slope = 0.84, intercept = 71.63)) +
geom_segment(df = data.frame(x = c(x5, x10, x15),
y = c(50, 60, 75),
aes(x, y, xend = x, yend = 0, colour = Gradient),
linetype = 2) +
geom_point(df = data.frame(load = c(x5, x10, x15),
VO2max = c(50, 60, 75),
coord_cartesian(ylim = c(0, 105), xlim = c(0, 25),
expand = 0) +
geom_hline(df = data.frame(y = c(50, 60, 75),
aes(yintercept = y, colour = Gradient), linetype = 2) +
theme_minimal() +
theme(axis.line = element_line()) +
guides(colour = "none")
```

• 6,000 points

+1 vote

## how to analysis the heatmap to find the correlation

Hi @Vikas, there are 5 simple steps ...READ MORE

## How to import the BatchNormalization function in Keras?

Hi@akhtar, The general use case is to use ...READ MORE

## Is there a way to force the coefficient of the independent variable to be a positive coefficient in the linear regression model used in R?

A Few Constraints This is an example of ...READ MORE

## How to get a regression summary in scikit-learn like R does?

In sklearn, there is no R type ...READ MORE

## How to plot side-by-side Plots with ggplot2 in R?

By Using gridExtra library we can easily ...READ MORE

+1 vote

## How to change fill color in each facet using ggplot2?

You can map the facetting variable to ...READ MORE

## Changing the legend title in ggplot

Hi, you can also try guides() to ...READ MORE

## How to order bars in a bar graph using ggplot2?

The key to ordering is to set ...READ MORE