How to make a scatterplot in R (with regression line)

116,673
0
Published 2017-06-23
This tutorial shows how to make a scatterplot in R. We also add a regression line to the graph. We also make a scatterplot with a third variable to add extra insight into our graph.

Thank you for watching this video. Make sure to like the video if you found it helpful and subscribe if you want to see more videos like this one!

All Comments (21)
  • Dude thankyou so much been stuck on this all day!! You’ve helped massively!!
  • @sonam502
    thank you! very simple, straight to the point and very organized
  • @SerafinKeilin
    You explained that easy and short and I understood it and it really helped right away, thanks alot!
  • Great video, but I am trying to do just this, had the same code you used. R didnt return any errors, but my regression line does not show up on my scatterplot. Any help on why that is would be appreciated.
  • @CB_2023
    I keep getting these errors when I plot 2 independent ad one dependent variable. How do I fix it??? ## Warning in scatterplot.default(X[, 2], X[, 1], groups = X[, 3], xlab = xlab, : number of groups exceeds number of available colors ## colors are recycled
  • Please I am working with several subsets of data, can I get an explanation on what to do. The question goes like this, for birth weights and pregnancy, I should assign women who smoke to 1, those who don't to 2, and those who never tried to 3. Them I should later plot a graph of the birth weight in addition to the pregnancy of those who didn't, thus 2.
  • @remonhany
    That was really helpful, THANK YOU!
  • @lilia.2869
    Thanks for the help! Very easy to follow
  • @volatility777
    I am a complete beginner in programming. Can someone tell me the proper way to enter ~ within the lm() function please? I have tried shift # but didn't work. Thanks
  • @tamerajames5590
    My scatter plots don’t look right, what am I doing wrong? Please help because my assignment is due Tuesday!
  • Hey! Thank you very much for your useful video. I was just wonderin though: somehow I have made it such that my plots appear in a new window (i.e not in the console). Every plot I do, it makes a new window that minimises when I change my code. How do I change it bac so that my plots appear only in the plot section of the console?
  • @AsirAjmal
    Please make more videos on R. I am a psychologist who likes your simple and easy method of teaching stats with R. Please also cover non linear models, ancova, manova, repeated measures etc in your future videos. But using the same easy method. Great stuff.
  • @21Arrozito
    is it necessary to specify the data source in the abline function? I tried with specifying it and without it and the same regression line still plots the same either way.
  • @Benjamin-el9sp
    thank you so much sir but can you show us how to calculate the p-value to see if this reverse correlation is significant enough?