0 correlation scatter plot3/14/2024 It can also color code the cells to reflect the size of the correlations. The gclus package provides options to rearrange the variables so that those with higher correlations are closer to the principal diagonal. Scatterplot.matrix(~mpg+disp+drat+wt|cyl, data=mtcars, # Scatterplot Matrices from the car Package The car package can condition the scatterplot matrix on a factor, and optionally include lowess and linear best fit lines, and boxplot, densities, or histograms in the principal diagonal, as well as rug plots in the margins of the cells. # Scatterplot Matrices from the lattice Package The latticepackage provides options to condition the scatterplot matrix on a factor. Analysts must love scatterplot matrices! # Basic Scatterplot Matrix There are at least 4 useful functions for creating scatterplot matrices. Xlab="Weight of Car", ylab="Miles Per Gallon", The scatterplot( ) function in the car package offers many enhanced features, including fit lines, marginal box plots, conditioning on a factor, and interactive point identification. Lines(lowess(wt,mpg), col="blue") # lowess line (x,y) (To practice making a simple scatterplot, try this interactive example from DataCamp.) # Add fit linesĪbline(lm(mpg~wt), col="red") # regression line (y~x) Xlab="Car Weight ", ylab="Miles Per Gallon ", pch=19) Plot(wt, mpg, main="Scatterplot Example", The basic function is plot( x, y ), where x and y are numeric vectors denoting the (x,y) points to plot. There are many ways to create a scatterplot in R.
0 Comments
Leave a Reply.AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |