Skip to content

Instantly share code, notes, and snippets.

@ChimeraCoder
Created December 9, 2013 17:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ChimeraCoder/7876545 to your computer and use it in GitHub Desktop.
Save ChimeraCoder/7876545 to your computer and use it in GitHub Desktop.
insertRow <- function(existingDF, newrow, r) {
existingDF[seq(r+1,nrow(existingDF)+1),] <- existingDF[seq(r,nrow(existingDF)),]
existingDF[r,] <- newrow
existingDF
}
removeDuplicates <- function(data){
result<- masterdata[1,]
for (i in 2:dim(masterdata)[1] ) {
mostRecentUniqueReading <- result[dim(result)[1],]
currentValue <- data[i,]
print(currentValue$messages)
print(mostRecentUniqueReading$messages)
if(currentValue$messages != mostRecentUniqueReading$messages){
result <- insertRow(result, currentValue, dim(result)[1]+1)
}
}
return(result)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment