Documente Academic
Documente Profesional
Documente Cultură
> 33+66
[1] 99
> 33+666
[1] 699
> 33+666
[1] 699
> 5*20
[1] 100
> a=5
> b=20
> c=a*b
> c
[1] 100
> a=c(28, 5.8, 59)
> a
[1] 28.0 5.8 59.0
> a[3]
[1] 59
> b<-3
> b
[1] 3
> 4->b
> b
[1] 4
> b<-c(1:90,215:2220)
> b<-c(1:90,215,220)
> b
[1] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
20
[21] 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
40
[41] 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59
60
[61] 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79
80
[81] 81 82 83 84 85 86 87 88 89 90 215 220
> b[22]
[1] 22
> class(b)
[1] "numeric"
> c=c("Shillong", "Meghalaya", "India")
> class(c)
[1] "character"
> c=c("Shillong", "Meghalaya", "India")
> class(c)
[1] "character"
> c
[1] "Shillong" "Meghalaya" "India"
> c[4]
[1] NA
> c[3]
[1] "India"
> d=c(b,c)
> class(d)
[1] "character"
> d
[1] "1" "2" "3" "4" "5" "6"
[7] "7" "8" "9" "10" "11" "12"
[13] "13" "14" "15" "16" "17" "18"
[19] "19" "20" "21" "22" "23" "24"
[25] "25" "26" "27" "28" "29" "30"
[31] "31" "32" "33" "34" "35" "36"
[37] "37" "38" "39" "40" "41" "42"
[43] "43" "44" "45" "46" "47" "48"
[49] "49" "50" "51" "52" "53" "54"
[55] "55" "56" "57" "58" "59" "60"
[61] "61" "62" "63" "64" "65" "66"
[67] "67" "68" "69" "70" "71" "72"
[73] "73" "74" "75" "76" "77" "78"
[79] "79" "80" "81" "82" "83" "84"
[85] "85" "86" "87" "88" "89" "90"
[91] "215" "220" "Shillong" "Meghalaya" "India"
> a
[1] 28.0 5.8 59.0
> e=list(a,c)
> class(e)
[1] "list"
> e
[[1]]
[1] 28.0 5.8 59.0
[[2]]
[1] "Shillong" "Meghalaya" "India"
> e[2][3]
[[1]]
NULL
> e[2,3]
Error in e[2, 3] : incorrect number of dimensions
> e[[2]][3]
[1] "India"
> e[[2]]
[1] "Shillong" "Meghalaya" "India"
> e[1]
[[1]]
[1] 28.0 5.8 59.0
> e[2]
[[1]]
[1] "Shillong" "Meghalaya" "India"
> class(e[2])
[1] "list"
> class(e[[2]])
[1] "character"
> m=matrix(c(1:9),nrow=3)
> class(m)
[1] "matrix"
> m
[,1] [,2] [,3]
[1,] 1 4 7
[2,] 2 5 8
[3,] 3 6 9
> m[1,1]
[1] 1
> m[2,1]
[1] 2
> m=matrix(c(1:9),nrow=3, byrow=T)
> m
[,1] [,2] [,3]
[1,] 1 2 3
[2,] 4 5 6
[3,] 7 8 9
> n=matrix(c(11:19),nrow=3, byrow=T)
> n
[,1] [,2] [,3]
[1,] 11 12 13
[2,] 14 15 16
[3,] 17 18 19
> o=m*n
> o
[,1] [,2] [,3]
[1,] 11 24 39
[2,] 56 75 96
[3,] 119 144 171
> p=m%*%n
> p
[,1] [,2] [,3]
[1,] 90 96 102
[2,] 216 231 246
[3,] 342 366 390
> savehistory("C:/Users/deepak/Desktop/Term 5/Business Intelligence and
Analytics/Session VII.Rhistory")
> setwd("C:/Users/deepak/Desktop/Term 5/Business Intelligence and Analytics")
> hsb=read.csv("hsb2.csv")
> class(hsb)
[1] "data.frame"
> hsb
id female race ses schtyp prog read write math science socst
1 70 0 4 1 1 1 57 52 41 47 57
2 121 1 4 2 1 3 68 59 53 63 61
3 86 0 4 3 1 1 44 33 54 58 31
4 141 0 4 3 1 3 63 44 47 53 56
5 172 0 4 2 1 2 47 52 57 53 61
6 113 0 4 2 1 2 44 52 51 63 61
7 50 0 3 2 1 1 50 59 42 53 61
8 11 0 1 2 1 2 34 46 45 39 36
9 84 0 4 2 1 1 63 57 54 58 51
10 48 0 3 2 1 2 57 55 52 50 51
11 75 0 4 2 1 3 60 46 51 53 61
12 60 0 4 2 1 2 57 65 51 63 61
13 95 0 4 3 1 2 73 60 71 61 71
14 104 0 4 3 1 2 54 63 57 55 46
15 38 0 3 1 1 2 45 57 50 31 56
16 115 0 4 1 1 1 42 49 43 50 56
17 76 0 4 3 1 2 47 52 51 50 56
18 195 0 4 2 2 1 57 57 60 58 56
19 114 0 4 3 1 2 68 65 62 55 61
20 85 0 4 2 1 1 55 39 57 53 46
21 167 0 4 2 1 1 63 49 35 66 41
22 143 0 4 2 1 3 63 63 75 72 66
23 41 0 3 2 1 2 50 40 45 55 56
24 20 0 1 3 1 2 60 52 57 61 61
25 12 0 1 2 1 3 37 44 45 39 46
26 53 0 3 2 1 3 34 37 46 39 31
27 154 0 4 3 1 2 65 65 66 61 66
28 178 0 4 2 2 3 47 57 57 58 46
29 196 0 4 3 2 2 44 38 49 39 46
30 29 0 2 1 1 1 52 44 49 55 41
31 126 0 4 2 1 1 42 31 57 47 51
32 103 0 4 3 1 2 76 52 64 64 61
33 192 0 4 3 2 2 65 67 63 66 71
34 150 0 4 2 1 3 42 41 57 72 31
35 199 0 4 3 2 2 52 59 50 61 61
36 144 0 4 3 1 1 60 65 58 61 66
37 200 0 4 2 2 2 68 54 75 66 66
38 80 0 4 3 1 2 65 62 68 66 66
39 16 0 1 1 1 3 47 31 44 36 36
40 153 0 4 2 1 3 39 31 40 39 51
41 176 0 4 2 2 2 47 47 41 42 51
42 177 0 4 2 2 2 55 59 62 58 51
43 168 0 4 2 1 2 52 54 57 55 51
44 40 0 3 1 1 1 42 41 43 50 41
45 62 0 4 3 1 1 65 65 48 63 66
46 169 0 4 1 1 1 55 59 63 69 46
47 49 0 3 3 1 3 50 40 39 49 47
48 136 0 4 2 1 2 65 59 70 63 51
49 189 0 4 2 2 2 47 59 63 53 46
50 7 0 1 2 1 2 57 54 59 47 51
51 27 0 2 2 1 2 53 61 61 57 56
52 128 0 4 3 1 2 39 33 38 47 41
53 21 0 1 2 1 1 44 44 61 50 46
54 183 0 4 2 2 2 63 59 49 55 71
55 132 0 4 2 1 2 73 62 73 69 66
56 15 0 1 3 1 3 39 39 44 26 42
57 67 0 4 1 1 3 37 37 42 33 32
58 22 0 1 2 1 3 42 39 39 56 46
59 185 0 4 2 2 2 63 57 55 58 41
60 9 0 1 2 1 3 48 49 52 44 51
61 181 0 4 2 2 2 50 46 45 58 61
62 170 0 4 3 1 2 47 62 61 69 66
63 134 0 4 1 1 1 44 44 39 34 46
64 108 0 4 2 1 1 34 33 41 36 36
65 197 0 4 3 2 2 50 42 50 36 61
66 140 0 4 2 1 3 44 41 40 50 26
67 171 0 4 2 1 2 60 54 60 55 66
68 107 0 4 1 1 3 47 39 47 42 26
69 81 0 4 1 1 2 63 43 59 65 44
70 18 0 1 2 1 3 50 33 49 44 36
71 155 0 4 2 1 1 44 44 46 39 51
72 97 0 4 3 1 2 60 54 58 58 61
73 68 0 4 2 1 2 73 67 71 63 66
74 157 0 4 2 1 1 68 59 58 74 66
75 56 0 4 2 1 3 55 45 46 58 51
76 5 0 1 1 1 2 47 40 43 45 31
77 159 0 4 3 1 2 55 61 54 49 61
78 123 0 4 3 1 1 68 59 56 63 66
79 164 0 4 2 1 3 31 36 46 39 46
80 14 0 1 3 1 2 47 41 54 42 56
81 127 0 4 3 1 2 63 59 57 55 56
82 165 0 4 1 1 3 36 49 54 61 36
83 174 0 4 2 2 2 68 59 71 66 56
84 3 0 1 1 1 2 63 65 48 63 56
85 58 0 4 2 1 3 55 41 40 44 41
86 146 0 4 3 1 2 55 62 64 63 66
87 102 0 4 3 1 2 52 41 51 53 56
88 117 0 4 3 1 3 34 49 39 42 56
89 133 0 4 2 1 3 50 31 40 34 31
90 94 0 4 3 1 2 55 49 61 61 56
[ reached getOption("max.print") -- omitted 110 rows ]
> head(hsb)
id female race ses schtyp prog read write math science socst
1 70 0 4 1 1 1 57 52 41 47 57
2 121 1 4 2 1 3 68 59 53 63 61
3 86 0 4 3 1 1 44 33 54 58 31
4 141 0 4 3 1 3 63 44 47 53 56
5 172 0 4 2 1 2 47 52 57 53 61
6 113 0 4 2 1 2 44 52 51 63 61
> tail(hsb)
id female race ses schtyp prog read write math science socst
195 179 1 4 2 2 2 47 65 60 50 56
196 31 1 2 2 2 1 55 59 52 42 56
197 145 1 4 2 1 3 42 46 38 36 46
198 187 1 4 2 2 1 57 41 57 55 52
199 118 1 4 2 1 1 55 62 58 58 61
200 137 1 4 3 1 2 63 65 65 53 61
> summary(hsb)
id female race ses schtyp
Min. : 1.00 Min. :0.000 Min. :1.00 Min. :1.000 Min. :1.00
1st Qu.: 50.75 1st Qu.:0.000 1st Qu.:3.00 1st Qu.:2.000 1st Qu.:1.00
Median :100.50 Median :1.000 Median :4.00 Median :2.000 Median :1.00
Mean :100.50 Mean :0.545 Mean :3.43 Mean :2.055 Mean :1.16
3rd Qu.:150.25 3rd Qu.:1.000 3rd Qu.:4.00 3rd Qu.:3.000 3rd Qu.:1.00
Max. :200.00 Max. :1.000 Max. :4.00 Max. :3.000 Max. :2.00
prog read write math science
Min. :1.000 Min. :28.00 Min. :31.00 Min. :33.00 Min. :26.00
1st Qu.:2.000 1st Qu.:44.00 1st Qu.:45.75 1st Qu.:45.00 1st Qu.:44.00
Median :2.000 Median :50.00 Median :54.00 Median :52.00 Median :53.00
Mean :2.025 Mean :52.23 Mean :52.77 Mean :52.65 Mean :51.85
3rd Qu.:2.250 3rd Qu.:60.00 3rd Qu.:60.00 3rd Qu.:59.00 3rd Qu.:58.00
Max. :3.000 Max. :76.00 Max. :67.00 Max. :75.00 Max. :74.00
socst
Min. :26.00
1st Qu.:46.00
Median :52.00
Mean :52.41
3rd Qu.:61.00
Max. :71.00
> describe(hsb)
Error in describe(hsb) : could not find function "describe"
> ?summary
> ?class
> ?describe
No documentation for ‘describe’ in specified packages and libraries:
you could try ‘??describe’
> install.packages("psych")
Installing package into ‘C:/Users/deepak/Documents/R/win-library/3.5’
(as ‘lib’ is unspecified)
also installing the dependency ‘mnormt’