In continuation to my previous post on scatter plot which was more of an introduction, in this post we will see step by step approach on doing scatter plot with R. Our objective in this post would be to draw a scatter plot using R step by step.
The following table provides the data which will be used in this post. This has two columns one is “Year” and another one is “Total Telephones” which is in millions.
Step 1: We have this data in a CSV file named “ScatterPlotData.csv”
Step 2: We will load this data using load.csv method using mydata=read.table(“E:\\Personal\\Learning\\Data Visualization\\ScatterPlotData.csv”,header=TRUE). This will handle the header and load the data appropriately.
Step 3: Now we have the data in mydata
Step 4: Now we can plot the Graph using the following statement :
plot(mydata$Year,mydata$TotalTelephones,main="Year Vs Sale of Telephones",xlab="Year",ylab="Sale of Telephones(Millions)",xaxt="n",ann="True")
axis(1, at=1:length(mydata$Year), lab=c(2004,2005,2006,2007,2008,2009,2010,2011,2012,2013))
Step 5: The Result