Skip to content

Commit

Permalink
Assignment-1-Part-1
Browse files Browse the repository at this point in the history
Solution
  • Loading branch information
Rajesh Subramanian committed Sep 13, 2014
1 parent d4965a0 commit 920e225
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
**/.Rhistory
**/.RHistory
**/.RData
**/.Rdata
**/specdata/*
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
pollutantmean <- function(directory, pollutant, id = 1:332) {
## 'directory' is a character vector of length 1 indicating
## the location of the CSV files

## 'pollutant' is a character vector of length 1 indicating
## the name of the pollutant for which we will calculate the
## mean; either "sulfate" or "nitrate".

## 'id' is an integer vector indicating the monitor ID numbers
## to be used

## Return the mean of the pollutant across all monitors list
## in the 'id' vector (ignoring NA values)

allFiles <- list.files(path = directory, full.names = TRUE)
selectedData <- data.frame()
for (i in id) {
selectedData <- rbind(selectedData, read.csv(allFiles[i]))
}
if (pollutant == 'sulfate') {
mean(selectedData$sulfate, na.rm = TRUE)
} else if (pollutant == 'nitrate') {
mean(selectedData$nitrate, na.rm = TRUE)
}

}
8 changes: 8 additions & 0 deletions samples/sample1.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
myfunction <- function() {
x <- rnorm(100)
mean(x)
}

second <- function(x) {
x + rnorm(length(x))
}

0 comments on commit 920e225

Please sign in to comment.