Your verification ID is: guDlT7MCuIOFFHSbB3jPFN5QLaQ Big Computing: Plotting in R (scatter plot, multicolor and linear regression) - Part 1

Tuesday, October 7, 2014

Plotting in R (scatter plot, multicolor and linear regression) - Part 1

Plot is the most basic grapphing function in R. I typically use it as a scatter plot to look for a relationship between two variables. The classic example of this is uses the build in data set in R called cars which measures the braking distance of a car versus its speed.
speed<-c(4,4,7,7,8,9,10,10,10,11,11,12,12,12,12,13,13,13,13,14,14,14,14,15,15,15,16,16,17,17,17,17,18,18,18,19,19,19,20,20,20,20,20,22,23,24,24,24,24,25)
dist<-c(2,10,4,22,16,10,18,26,34,17,28,14,20,24,28,26,34,34,46,26,36,60,80,20,26,54,32,40,32,40,50,42,56,76,84,36,46,68,32,48,52,56,64,66,54,70,92,93,120,85)
car<-as.data.frame(cbind(speed,dist))
plot(car)
plot of chunk unnamed-chunk-1
R’s format is very flexible. We could have also done plot(dist~speed,cars) or plot(cars[,1],cars[,2]) and gotten exact the same plot.
To test for a linear regression we might as well add the regression line to the plot
plot(car)
abline(lm(dist~speed,car))
plot of chunk unnamed-chunk-2
Rarely in recent times is a data set so small. Most data sets we see today are large and messier than this one.

6 comments:

  1. awesome post presented by you..your writing style is fabulous and keep update with your blogs Data Science online Course Hyderabad

    ReplyDelete
  2. Rarely in recent times is a data set so small. Most data sets we see today are large and messier than this one. black salwar kameez for ladies , black suit design salwar kameez ladies ,

    ReplyDelete
  3. You have a good point here! I totally agree with what you have said!! Thanks for sharing your views. hope more people will read this article!! 메이저사이트

    ReplyDelete
  4. I book marked it to my bookmark webpage list and will be checking back in the near future. Please visit my web site too and let me know what you think. 경마사이트

    ReplyDelete
  5. After looking at a handful of the articles on your blog, I truly like your technique of writing a blog. 카지노사이트

    ReplyDelete
  6. I have read so many posts regarding the blogger lovers
    but this article is truly a good paragraph, keep it up. 사설토토

    ReplyDelete