decheck <-
function(file1, file2){
if(file1 == file2){
stop("Can not compare the file with itself")
}
dat1 <- read.xlsx(xlsxFile = file1, sheet = 1, startRow=1, skipEmptyRows=FALSE, colNames=TRUE)
dat2 <- read.xlsx(xlsxFile = file2, sheet = 1, startRow=1, skipEmptyRows=FALSE, colNames=TRUE)
ind <- rep(FALSE, nrow(dat1))
for(i in 1:ncol(dat1)){
dat1[,i][which(is.na(dat1[,i]))] <- "N/A"
dat2[,i][which(is.na(dat2[,i]))] <- "N/A"
temp <- which(!dat1[,i] == dat2[,i])
ind[temp] <- TRUE
dat1[temp,i] <- paste("**<font color=\"red\">", dat1[temp,i],"</font>**", sep = "")
dat2[temp,i] <- paste("**<font color=\"red\"> ", dat2[temp,i],"</font>**", sep = "")
}
if(any(ind)){
title0 <- "DOUBLE ENTRY COMPARISONS"
aa1 <- paste("Excel File 1, Row ",which(ind), "\n")
aa <- kable(dat1[ind,], format = "markdown", output = FALSE)
bb1 <- paste("Excel File 2, Row ",which(ind), "\n")
bb <- kable(dat2[ind,], format = "markdown", output = FALSE)
markdownToHTML(text = c(title0,"=======","\n",
aa1,"\n",
aa, "\n",
bb1,"\n",
bb ,"\n",
"*This file was generated by function* `decheck()` *in R Package* **TPK** *Version 0.1* at: ", date(), "\n",
"**TPK** was written by **Jinlong Zhang** (jinlongzhang01@gmail.com) for Tai Po Kau Forest Plot in Hong Kong."),
output = "Excel_Comparison_Results.html")
} else {
cat("The Inputting Excel files are Identical! Cross Validation Passed.\n")
}
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.