Friday, 29 March 2013

Assignment #10 : 26th March,2013


Assignment No 10


Problem 1:-
Ques-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)
Create 3 dimensional plot of the same (all 3 types)
Solution:-
Commands:-
> sample<-rnorm(50,25,6)
> x<-sample(sample,10)
> y<-sample(sample,10)
> z<-sample(sample,10)
> T<-cbind(x,y,z)
 Screenshots:-
Image
> plot3d(T)
Image
plot3d(T,col=rainbow(1000))
Image
plot3d(T,col=rainbow(1000),type=’s')
Image


Problem 2:-
Read the documentation of rnorm and pnorm and 
Create 2 random variables
Create 3 plots:
1. X-Y
2. X-Y|Z (introducing a variable z and cbind it to z and y with 5 diff categories) Hint: ?factor
3. Color code and draw the graph
4. Smooth and best fit line for the curve
Solution:-
Commands:-
> x<-rnorm(200,mean=5,sd=1)
> y<-rnorm(200,mean=3,sd=1)
> z1<-sample(letters,5)
> z2<-sample(z1,200,replace=TRUE)
> z<-as.factor(z2)
> t<-cbind(x,y,z)
Screenshots:-
Image
> qplot(x,y)
Image
> qplot(x,z,alpha=I(2/10))
Image
> qplot(x,z)

Image
> qplot(x,y,geom=c(“point”,”smooth”))
Image
> qplot(x,y,colour=z)
Image
> qplot(log(x),log(y),colour=z)
Image

No comments:

Post a Comment