-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathlab1.R
More file actions
21 lines (21 loc) · 659 Bytes
/
lab1.R
File metadata and controls
21 lines (21 loc) · 659 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
my.display <- function(x, display = FALSE, type = "", prob = TRUE) {
#type = 'hist' || 'density'
if (display & type == "") {
return(cat("Please specify type as either hist or density"))
} else if (display & type == 'hist') {
return(hist(x, freq = prob))
} else if (display & type == 'density') {
return(density(x))
} else {
#return('N args specified')
median(x)
}
#cat('summary of input:\n', summary(x))
}
set.seed(1234)
my.data<-rnorm(200)
my.display(my.data)
my.display(my.data,display=TRUE,type="hist")
my.display(my.data,display=TRUE,type="hist",prob=TRUE)
my.display(my.data,display=TRUE,type="density")
my.display(my.data,display=TRUE)