Date 26-03-2013
Assignment 1 :
Create 3 vectors, x, y, z and choose any random values for them, ensuring they are of equal length,
Create a 3D vector by binding the 3 individual vectors
Create 3 dimensional plot of the same.
Solution :
Step1:
Creating a dataset with the help of rnorm
Step2:
Sampling 3 vectors of equal length from the above data set
Step3:
Binding the 3 vectors together to create a 3-D vector
3D plotting
Type1:
plot3d(T[,1:3])
Type2: with axis labels and color
plot3d(T[,1:3],xlab="X Axis" , ylab="Y Axis" , zlab="Z Axis", col=rainbow(5000))
Type3: with axis labels ,color and points type as spheres
plot3d(T[,1:3],xlab="X Axis" , ylab="Y Axis" , zlab="Z Axis", col=rainbow(5000), type="s")
Type4: with axis labels ,color and points type as lines
plot3d(T[,1:3],xlab="X Axis" , ylab="Y Axis" , zlab="Z Axis", col=rainbow(5000), type="l")
Assignment 2:
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)
3. Color code and draw the graph
4. Smooth and best fit line for the curve
Solution :
Step1:
Create 2 random variables x,y using rnorm
Add a 3rd variable by sampling data and using the factor as shown -:
graphs
Type1:
qplot between x and y
Command used
qplot(x,y)
Type2:
qplot between x and z
Command used
qplot(x,z)
Type 3
Semi transparent qplot between x and z with alpha
Semi transparent qplot between x and z with alpha
Command used
qplot(x,z , alpha=I(4/10))
Type 4:
colored plot
Command used
qplot(x,y , color=z)
Type 5:
Logarithmic colored plot
Command used
qplot(log(x),log(y) , color=z)
Type 6:
smooth curve and best fit line using geom
Command used
Command used
qplot(x,y,geom=c("point","smooth"))
Command used
qplot(x,y,geom=c("boxplot","jitter"))



















































