-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgetmonitor.R
More file actions
36 lines (21 loc) · 879 Bytes
/
getmonitor.R
File metadata and controls
36 lines (21 loc) · 879 Bytes
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
getmonitor <- function (id, directory, summarize= FALSE )
{
## 'id' is a vector of length 1 indicating the monitor ID
## number. The user can specify 'id' as either an integer, a
## character, or a numeric.
## 'directory' is a character vector of length 1 indicating
## the location of the CSV files
## 'summarize' is a logical indicating whether a summary of
## the data should be printed to the console; the default is
## FALSE
## Your code here
id = as.numeric(id)
##directory = as.character(directory)
if (id <= 9) id=paste("00",id,sep="")
else { if (id<=99) id=paste("0",id,sep="")
}
f = paste(directory,"/",id,".csv",sep="")
data <- read.csv(f, header=T, colClasses= c(Date = "Date",sulphate="numeric",nitrate="numeric",ID="integer"))
if (summarize ) print(summary(data))
else data
}