Thursday, 28 March 2013

ITBAL ASSIGNMENT 9

Assignment 1:
Create 3 vectors x,y,z : choose any random values for each of equal length
T<-cbind(x,y,z)
create 3d plot and colour code it. 


> datasample<- rnorm(76,52,34)
> datasample


 [1]  45.5942618  19.9666328  57.2714050  74.3639975  40.3385894   0.6364362  74.7431400 115.0645893  25.1070366  43.4188552  63.1523647  23.6176277  67.2653427
[14]  26.6219515  49.4166552  28.8174814  57.3325996  97.7983760  26.1854705  78.6355984  73.4513727 -27.5435911  68.3513575  17.8148926  67.5888141  67.6574094
[27]  -3.3454215  34.3924609  18.6275779 115.7888569  40.8016886 102.1727834  98.8360943  64.2131752  47.0419500  43.7890566  47.7691718 104.9063673  86.8813250
[40]  67.8444825  81.9504910  46.9187240  79.7412471  28.9433658  43.8613800  32.6041700  63.0511048  55.7572267  36.0072830  79.1773860  71.5129731  40.6598254
[53]  31.8630136  86.6888350  38.7001328  58.0645384  63.0741548 107.4190386  52.7611391   7.0894044  27.9309929  84.1651360 -42.5948954  39.2538138  -2.4216676
[66]  56.2117049  65.6911771  73.2045687  91.1742967  58.5928354 116.0099456  25.0099455  30.3843329  -1.5303707  50.1393531  95.2141598

> x<- sample(datasample,20)
> y<- sample(datasample,20)
> z<- sample(datasample,20)
> x


 [1]  71.51297  79.17739  97.79838  28.81748  30.38433  58.06454  31.86301  67.26534  25.00995  43.86138  28.94337  56.21170  73.45137  95.21416  26.62195  84.16514
[17]  23.61763 104.90637  40.80169 116.00995
> y
 [1]  91.17430  84.16514  73.20457 104.90637  67.84448  32.60417 107.41904 102.17278  18.62758 -27.54359  73.45137  47.04195  63.07415 115.06459  65.69118  28.94337
[17]  78.63560  56.21170  39.25381  19.96663
> z
 [1]  46.9187240  67.5888141  43.7890566 116.0099456  38.7001328  25.1070366  67.8444825 107.4190386  45.5942618  -1.5303707  63.1523647  47.0419500 115.7888569
[14]  57.3325996  68.3513575  79.7412471   0.6364362  67.6574094  58.0645384  73.2045687
> T<-cbind(x,y,z)
> T

              x         y           z
 [1,]  71.51297  91.17430  46.9187240
 [2,]  79.17739  84.16514  67.5888141
 [3,]  97.79838  73.20457  43.7890566
 [4,]  28.81748 104.90637 116.0099456
 [5,]  30.38433  67.84448  38.7001328
 [6,]  58.06454  32.60417  25.1070366
 [7,]  31.86301 107.41904  67.8444825
 [8,]  67.26534 102.17278 107.4190386
 [9,]  25.00995  18.62758  45.5942618
[10,]  43.86138 -27.54359  -1.5303707
[11,]  28.94337  73.45137  63.1523647
[12,]  56.21170  47.04195  47.0419500
[13,]  73.45137  63.07415 115.7888569
[14,]  95.21416 115.06459  57.3325996
[15,]  26.62195  65.69118  68.3513575
[16,]  84.16514  28.94337  79.7412471
[17,]  23.61763  78.63560   0.6364362
[18,] 104.90637  56.21170  67.6574094
[19,]  40.80169  39.25381  58.0645384
[20,] 116.00995  19.96663  73.2045687


> plot3d(T)


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


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




Assignment2:
Read the documentaion of rnorm,pnorm
Create two random variables x and y which are normally   distributed
Plot x vs y
Plot x vs y after introducing a categorical variable using   cbind with 5 diff categories
Get the colourcode
Get the smooth curve


> ?rnorm
starting httpd help server ... done

http://127.0.0.1:31992/library/stats/html/Normal.html

> x <- rnorm(200,90,10)
> y <- rnorm(200,50,10)
> z1<-sample(letters,5)
> z2<-sample(z1,200,replace=TRUE)
> z<-as.factor(z2)
> T<-cbind(x,y,z)
> qplot(x,y)




> qplot(x,z)




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



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



>  qplot(x,y,colour=z)




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






No comments:

Post a Comment