-
Notifications
You must be signed in to change notification settings - Fork 0
/
Access data.R
80 lines (72 loc) · 1.71 KB
/
Access data.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
access_data<-function(dataset)
{
nc<-ncol(dataset)
cat("Different columns in the given dataset\n")
col_names<-colnames(dataset) ##extract column names
for(i in seq_len(nc)){
cat(col_names[i],"\n")
}
nr<-nrow(dataset)
min_data<-numeric()
max_data<-numeric()
mean_data<-numeric()
median_data<-numeric()
quartile_data<-matrix(0,nrow=3,ncol=nc-1)
i<-2
sum<-0
max<-0
min<-0
while(i<=nc)
{
for(j in seq_len(nr))
{
if(j==1)
{
max<-dataset[j,i]
min<-dataset[j,i]
}
else{
if(max<dataset[j,i])
max<-dataset[j,i]
if(min>dataset[j,i])
min<-dataset[j,i]
}
sum<-sum+dataset[j,i]
}
mean_data[i-1]<-sum/nr
min_data[i-1]<-min
max_data[i-1]<-max
i<-i+1
sum<-0
}
col_data<-numeric()
i<-2
while(i<=nc)
{
col_data<-c()
for(j in seq_len(nr))
{
col_data<-c(col_data,dataset[j,i])
}
col_data<-sort(col_data,decreasing = FALSE)
if(nr%%2!=0)
{
median_data[i-1]<-col_data[ceiling(nr/2)]
quartile_data[1,i-1]<-col_data[ceiling(nr/4)]
quartile_data[2,i-1]<-median_data[i-1]
quartile_data[3,i-1]<-col_data[ceiling(3*nr/4)]
}
else
{
median_data[i-1]<-(col_data[nr/2]+col_data[(nr/2)+1])/2
quartile_data[1,i-1]<-col_data[ceiling(nr/4)]
quartile_data[2,i-1]<-median_data[i-1]
quartile_data[3,i-1]<-col_data[ceiling(3*nr/4)]
}
i<-i+1
}
cat("Descriptive Analysis\n")
display_descriptive_analysis(nc,col_names,min_data,max_data,mean_data,median_data,quartile_data)
regression_forecast(dataset)
return
}