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)
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:-
> plot3d(T)
plot3d(T,col=rainbow(1000))
plot3d(T,col=rainbow(1000),type=’s')
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
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)
> 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:-
> qplot(x,y)
> qplot(x,z,alpha=I(2/10))
> qplot(x,z)
> qplot(x,y,geom=c(“point”,”smooth”))
> qplot(x,y,colour=z)
> qplot(log(x),log(y),colour=z)



