Commits

Ryan Tracey  committed 2594dc0

week2 second task

  • Participants
  • Parent commits 7bbb82f

Comments (0)

Files changed (3)

File coursera/week2/complete.R

+complete <- function(directory, id = 1:332) {
+    ## 'directory' is a character vector of length 1 indicating
+    ## the location of the CSV files
+    
+    ## 'id' is an integer vector indicating the monitor ID numbers
+    ## to be used
+      
+    ## Return a data frame of the form:
+    ## id nobs
+    ## 1  117
+    ## 2  1041
+    ## ...
+    ## where 'id' is the monitor ID number and 'nobs' is the
+    ## number of complete cases
+
+    mydata = data.frame()
+    for(item in id) {
+        file = sprintf("%s/%03d.csv", directory, item)
+        data = read.csv(file)
+        #gdata = complete.cases(data)
+        #good = data[gdata,]
+        good = data[complete.cases(data),]
+        rows = nrow(good)
+        mydata <- rbind(mydata, c(item, rows))
+    }
+    names(mydata) <- c("id", "nobs")
+    return(mydata)
+}

File coursera/week2/getmonitor-testoutput1.txt

+0.118
+0.2835
+0.453
+0.5499
+0.6635
+1.83
+1339
+1.7
+3.062
+4.345
+6.267
+7.435
+22.1
+666

File coursera/week2/getmonitor-testoutput2.txt

+0.704
+2.605
+2.4
+0.73