0% found this document useful (0 votes)
26 views8 pages

1) A - 10:100 Barplot (A) : Exercise Number 3

This document contains 24 exercises using R to analyze and visualize data. The exercises include creating bar plots, scatter plots, contour plots and 3D surface plots of sample data. Descriptive statistics like mean, variance and covariance are calculated for variables in the iris dataset. Various plots like histograms, density plots and boxplots are used to visualize distributions of variables in iris. Pairwise relationships between variables are explored using pairs plots.

Uploaded by

theultimateaim
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
26 views8 pages

1) A - 10:100 Barplot (A) : Exercise Number 3

This document contains 24 exercises using R to analyze and visualize data. The exercises include creating bar plots, scatter plots, contour plots and 3D surface plots of sample data. Descriptive statistics like mean, variance and covariance are calculated for variables in the iris dataset. Various plots like histograms, density plots and boxplots are used to visualize distributions of variables in iris. Pairwise relationships between variables are explored using pairs plots.

Uploaded by

theultimateaim
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 8

Lakshya Gupta

131100029

EXERCISE NUMBER 3
1) a<- 10:100
barplot(a)

2)barplot(1:100)

3)x<- (1:5)
y <- c(2,4,6,8,10)
plot(x,y)

1 | Page

Lakshya Gupta
131100029

4) b<- c(10,NA,20)
sum(b,na.rm=TRUE)
[1] 30
5) z<- matrix((1:8),nr=4,nc=2,byrow=TRUE)
contour(z)

6)persp(z)

2 | Page

Lakshya Gupta
131100029

7)elevation<- z
persp(elevation,expand=0.2)

8) contour(volcano)

9)persp(volcano,expand=0.2)

3 | Page

Lakshya Gupta
131100029

10) image(volcano)

11) str(iris)
'data.frame': 150 obs. of 5 variables:
$ Sepal.Length: num 5.1 4.9 4.7 4.6 5 5.4 4.6 5 4.4 4.9 ...
$ Sepal.Width :num 3.5 3 3.2 3.1 3.6 3.9 3.4 3.4 2.9 3.1 ...
$ Petal.Length: num 1.4 1.4 1.3 1.5 1.4 1.7 1.4 1.5 1.4 1.5 ...
$ Petal.Width :num 0.2 0.2 0.2 0.2 0.2 0.4 0.3 0.2 0.2 0.1 ...
$ Species

: Factor w/ 3 levels "setosa","versicolor",..: 1 1 1 1 1 1 1 1 1 1 ...

12)dim(iris)
[1] 150 5
13)names(iris)
4 | Page

Lakshya Gupta
131100029

[1] "Sepal.Length" "Sepal.Width" "Petal.Length" "Petal.Width" "Species"


14)attributes(iris)
$names
[1] "Sepal.Length" "Sepal.Width" "Petal.Length" "Petal.Width" "Species"

$row.names
[1] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
[19] 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
[37] 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54
[55] 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72
[73] 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90
[91] 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108
[109] 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126
[127] 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143
144
[145] 145 146 147 148 149 150

$class
[1] "data.frame"

15)summary(iris)
Sepal.LengthSepal.WidthPetal.LengthPetal.Width
Min.:4.300 Min. :2.000 Min. :1.000 Min. :0.100
1st Qu.:5.100 1st Qu.:2.800 1st Qu.:1.600 1st Qu.:0.300
5 | Page

Lakshya Gupta
131100029

Median :5.800 Median :3.000 Median :4.350 Median :1.300


Mean :5.843 Mean :3.057 Mean :3.758 Mean :1.199
3rd Qu.:6.400 3rd Qu.:3.300 3rd Qu.:5.100 3rd Qu.:1.800
Max. :7.900 Max. :4.400 Max. :6.900 Max. :2.500
Species
setosa

:50

versicolor:50
virginica :50

16) table(iris$Species)
setosaversicolorvirginica
50

50

50

17)pie(table(iris$Species))

18)var(iris$Sepal.Length)
[1] 0.6856935
19)hist(iris$Sepal.Length)

6 | Page

Lakshya Gupta
131100029

20)plot(density(iris$Sepal.Length))

21)cov(iris$Sepal.Length,iris$Petal.Length)
[1] 1.274315
22)pairs(iris)

7 | Page

Lakshya Gupta
131100029

23)plot(iris$Sepal.Length,iris$Sepal.Width)

24) boxplot(iris$Sepal.Length)

8 | Page

You might also like