Friday, 29 March 2013

R statistical Tool Assignment-7

In this class we were introduced to the method of creating 3-Dimensional plots of a particular Data set 

Assignment 1-Create 3 vectors, x, y, z and choose any random values for them, ensuring they are of equal length,T<- cbind(x,y,z) Also create a 3-dimensional plot for the same.
 Command:-
> #generating a Random sample for the purpose using the function Rnorm . The code is "rnorm( n, mean, sd ); if the Mean and SD are not specified they are assumed to be as 0 and 1 respectively. The function generates random numbers whose distribution is normal. The n specifies the number of Random nos you want while the optional arguments are the mean and the S.D values.

> sample<-rnorm(50,25,6)

> sample 

> x<-sample(sample,10)

> x

> y<-sample(sample,10)

> y

> z<-sample(sample,10)

> z

> T<-cbind(x,y,z)

> T



> plot3d(T)

> plot3d(T, col=rainbow(1000))

> # here "col" denotes the color of the data points;


> plot3d(T,col=rainbow(1000),type="s")



Assignment-2 :- Create 2 random variables Create 3 plots: 
> #1. X-Y ,X-Y|Z (introducing a variable z and cbind it to x and y with 5 diff categories) 

> x<-rnorm(1500,100,10)

> y<-rnorm(1500,85,5)

> z1<-sample(letters,5)

> z2<-sample(z1,1500,replace=TRUE)

> z<-as.factor(z2)

> t<-cbind(x,y,z)

> qplot(x,y)


> qplot(x,z)

> qplot(x,z,alpha=l(1/10))

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

> qplot(x,y,color=z)

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









No comments:

Post a Comment