-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLists_and_functions.R
More file actions
49 lines (33 loc) · 1.2 KB
/
Lists_and_functions.R
File metadata and controls
49 lines (33 loc) · 1.2 KB
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
mod <- lm(eruptions ~ waiting, data=faithful)
#----------------------------------------------------------------------------------------------------------------------------
#Function 1: get_data()
get_data<- function(a,x)
{
a$model[[x]]
}
d <- get_data(mod,"waiting")
d[1:20]
#----------------------------------------------------------------------------------------------------------------------------
#Function 2: get_coefficient()
get_coefficient<-function(a,x)
{
a$coefficients[x]
}
c <- get_coefficient(mod,"waiting")
c
#----------------------------------------------------------------------------------------------------------------------------
#Function 3: get_residuals()
get_residuals<-function(a)
{
list("data" = a$residuals, "mean" = mean(a$residuals), "number" =length(mod$residuals))
}
r <- get_residuals(mod)
str(r)
#----------------------------------------------------------------------------------------------------------------------------
#Function 4: mod_summary()
mod_summary<-function(a)
{
list("call"=summary(a)$call , "coeff"=summary(a)$coefficients[,1],"datasize"=list("rows"=nrow(a$model),"cols"=ncol(a$model)))
}
s <- mod_summary(mod)
s