Visualization

July 17, 2016 | Author: Abhik Seal | Category: Types, Instruction manuals
Share Embed Donate


Short Description

Exploring data with R...

Description

Exploring Data with R Abhik Seal May 8, 2014 This is a introductory tutorial to get you started with Visualization data and Exploring Data with R. There are some popular books and many online materials i will Provide the links and references at the end of the tutorial. library(ggplot2) library(gcookbook)

Scatter Plots and line plots plot(cars$dist~cars$speed, # y~x main="Relationship between car distance & speed", #Plot Title xlab="Speed (miles per hour)", #X axis title ylab="Distance travelled (miles)", #Y axis title xlim=c(0,30), #Set x axis limits from 0 to 30 yaxs="i", #Set y axis style as internal col="red", #Set the colour of plotting symbol to red pch=19) #Set the plotting symbol to filled dots

80 60 40 20

Distance travelled (miles)

120

Relationship between car distance & speed

0

5

10

15

20

25

30

Speed (miles per hour) Let’s draw vertical error bars with 5% errors on our cars scatterplot using arrows function

1

25 20 10

15

mpg

30

plot(mpg~disp,data=mtcars) arrows(x0=mtcars$disp, y0=mtcars$mpg*0.95, x1=mtcars$disp, y1=mtcars$mpg*1.05, angle=90, code=3, length=0.04, lwd=0.4)

100

200

300

400

disp How to draw histograms in the top and right margins of a bivariate scatter plot layout(matrix(c(2,0,1,3),2,2,byrow=TRUE), widths=c(3,1), heights=c(1,3), TRUE) par(mar=c(5.1,4.1,0.1,0)) plot(cars$dist~cars$speed, # y~x xlab="Speed (miles per hour)", #X axis title ylab="Distance travelled (miles)", #Y axis title xlim=c(0,30), #Set x axis limits from 0 to 30 ylim=c(0,140), #Set y axis limits from 0 to yaxs="i", #Set y axis style as internal col="red", #Set the colour of plotting symbol to red pch=19) #Set the plotting symbol to filled dots par(mar=c(0,4.1,3,0)) hist(cars$speed,ann=FALSE,axes=FALSE,col="black",border="white") yhist
View more...

Comments

Copyright ©2017 KUPDF Inc.
SUPPORT KUPDF