Add two lines on graph using abline in R

0 votes
I'm working with two variables:

x=rnorm(10, 5, 1) x=c(rnorm(10, 5, 1) x=c(rnorm(10

y=rnorm(10, 5, 1) y=c(rnorm(10, 5, 1) y=c(rnorm(10

I want to plot a vertical line at the corresponding x value of the maximum y. I tried abline(v=max(y)) but that did not bring the line up. I am able to get a horizontal line for that max(y) but no vertical line for the corresponding x. I want two line on the point, essentially.
Jun 13, 2022 in Data Science by Avinash
• 1,260 points
559 views

1 answer to this question.

0 votes

I am using "y 0+x" to fit a model without an intercept as I implement a linear model in R. Why does the line not pass through the origin when I use "abline(0, 2.08193)"? How can this be fixed?

x <- c

(2.9, 6.7, 8.0, 3.1, 2.0, 4.1, 2.2, 8.9, 8.1, 7.9, 5.7, 1.6, 6.6, 3.0, 6.3)

y <- c

(5.118289 17.168719 14.489016 7.340286 8.422882 7.994184 4.455667 17.529257 16.628453 17.076216 14.855261 2.596441 12.039215 6.684931 11.456480)

mod0 <- lm(formula = y ~ 0+x)

plot(x,y, xlab="x ", ylab="y ")

summary(mod0)

Discover the world of data with our Data Science Course and embark on a transformative journey towards analytical excellence.

answered Jun 24, 2022 by Sohail
• 3,040 points

Related Questions In Data Science

0 votes
0 answers

Stepwise AIC using forward selection in R

In R, I'm attempting to perform a ...READ MORE

Jun 24, 2022 in Data Science by Sohail
• 3,040 points
407 views
0 votes
0 answers

Understanding of minbucket function in CART model using R

Let's say that the training data is ...READ MORE

Jul 20, 2022 in Data Science by avinash
• 1,840 points
507 views
0 votes
0 answers

How to plot two histograms together in R?

I have two data frames, one each ...READ MORE

Jul 22, 2022 in Data Science by avinash
• 1,840 points
400 views
0 votes
0 answers

Introduction to Statistical Learning with Applications in R Figure Codes

I recently bought the following book: An Introduction ...READ MORE

Jun 1, 2022 in Data Science by avinash
• 1,840 points
533 views
0 votes
1 answer

Difference between the == and %in% operators in R

According to help('percent in percent'), percent in ...READ MORE

answered Jun 23, 2022 in Data Science by Sohail
• 3,040 points
462 views
0 votes
1 answer

How to make loop for one-at-a time logistic regression in R?

You're probably looking for something similar to ...READ MORE

answered Jun 20, 2022 in Data Science by Sohail
• 3,040 points
984 views
0 votes
1 answer

do-while loop in R

Unlike for and while loops, which test the loop condition at ...READ MORE

answered Jun 1, 2022 in Data Science by Sohail
• 3,040 points
633 views
0 votes
1 answer

What does c do in R?

The c function in R programming usually stands ...READ MORE

answered Jun 1, 2022 in Data Science by Sohail
• 3,040 points

edited Nov 28, 2023 by Soumya 23,354 views
0 votes
1 answer

How to implement Knn-algorithm without using k-nn function in r?

I created an example that demonstrates the ...READ MORE

answered Jun 24, 2022 in Data Science by Sohail
• 3,040 points
415 views
0 votes
1 answer

Difference between the == and %in% operators in R

percent in percent "returns a vector of ...READ MORE

answered Jun 20, 2022 in Data Science by Sohail
• 3,040 points
679 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP