Visualization in R(Assignment 9)
Greetings Professor,
In this assignment#9, I learned about how visualize the data in R Programming by using three different ways like Basic Graphs, Lattice and ggplot2 from RStudio.
At first we have to download the dataset(USConsumption1950) from the web or internet and import the dataset into the RStudio by using import dataset. Then for the visualization of Basic Graphs I used plot() to the dataset.
>plot(USConsump1950)
>plot(USConsump1950, main="My Scatterplot")
And for the aesthetic and elegant visualization of dataset I use "lattice" method.
>library(lattice)
>splom(USConsump1950[,c("income","expenditure")], col="blue",main="Scatter Plot Matrix of income and expenditure")
>splom(USConsump1950[,c("income","expenditure")], col="red",main="Scatter Plot Matrix of income and expenditure")
And for the creation of the graphical plots visualization of dataset I used "ggplot2" method: >library(ggplot2)
> ggplot(data= USConsump1950, aes(x=income,y=expenditure)) + geom_point()+ geom_smooth(method = "lm", formula = "y ~ poly(x,2)",se= FALSE)+labs(title= "Scatter Plot of income and expenditure with Quadratic Regression Line",x="income",y="expenditure")
Comments
Post a Comment