Friday, March 29, 2013

SESSION 10

ASSIGNMENT 1:

Create 3 vector x,y,z and choose any random value for them , ensuring they are of equal length, bind them together. Create different 3 dimensional plots for the same.

Solution:

> ranvec<- rnorm(20,40,60)
> ranvec
> x<-sample(ranvec,15)
> y<-sample(ranvec,15)
> z<-sample(ranvec,15)
> A<-cbind(x,y,z)
> plot3d(A)


>plot3d([,1:3],col=rainbow(1000))



>plot3d([,1:3],col=rainbow(1000), type='s')


>plot3d([,1:3],col=rainbow(1000), type='h')


>plot3d([,1:3],col=rainbow(1000), type='l')



ASSIGNMENT 2: Read the documentation of rnorm and pnorm choose 2 random variable and create 3 plots :
(a) X-Y
(b) X-Y|Z(Introducing a variable z and cbind it to z and y with diff categories)
(c) color code and draw the graph
(d) Smooth and best fit line


Data set creation for two random samples 

> x<-rnorm(1000,50,20)
> y<-norm(1000,25,10)
> z1<-sample(letters,10)
> z2<-sample(z1,1000, replace= TRUE)
> z <-as.factors(z2)
> z



>qplot(x,y)

>qplot(x,z)

>qplot(x,z,alpha=I(2/10))

>qplot(x,y,color=z)

>qplot(log(x),log(y),color=z)

>qplot(x,y,geom=c("path","smooth"))

>qplot(x,y,geom=c("point","smooth"))

>qplot(x,y,geom=c("boxplot","jitter"))








No comments:

Post a Comment