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

Tuesday, October 7, 2014

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

Also we may want to plot points on a graph where the points are of different classes or groups. Below I create a data set with four variable that all have a linear relationship to each other.
group<-data.frame()
indep<-runif(900,0,10)
dep1<-5*indep[1:300]+rnorm(300,3,3)
dep2<-7*indep[301:600]+rnorm(300,2,6)
dep3<-9*indep[601:900]+rnorm(300,1,7)
deps<-c(dep1,dep2,dep3)
group[1:300,1]<-1
group[301:600,1]<-2
group[601:900,1]<-3
groups<-cbind(indep,deps,group)
When we plot without speerating the groups it looks like there might be a linear relationship. However, if you look closely you will see that the plot is slightly cone shaped which should tell you there is something else going on.
plot(deps~indep,groups)