Data Visualization: Scatter Plot step by step with R

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.

Background:

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.

 Source: http://mospi.nic.in/Mospi_New/upload/SYB2014/ch31.html

 Source Data:


Steps:

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 :

mydata=read.table("E:\\Personal\\Learning\\Data Visualization\\ScatterPlotData.csv",header=TRUE)
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

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s