###############################################################################
#           COA DISSERTATION IN R     www.RobinJamesMayes.com                 #
###############################################################################
# Source Contributors:     Mayes
###############################################################################
rm(list=ls())
library(moments); library(plyr) 

setwd("F:/COA_PhD_Dissertation/R-STATS")

############## Import data from CSV text file & attache to R ##################

dtaCORPUS <- read.csv("F:/COA_PhD_Dissertation/R-STATS/SRTCSV_CORPUS-20170327.CSV", header=TRUE)

DS_ALL<-subset(dtaCORPUS)

DS_DIS<-subset(dtaCORPUS, dcmDOCTYP==1)  

DS_ART<-subset(dtaCORPUS, dcmDOCTYP==2) 

options(max.print=50000)

###############################################################################
# Simple Histograms visually examining normality (Skewness and Kurtosis).
hist(DS_ALL$dcmGRSDSI, main="Turnitin Reported DSI", xlab="Reported DSI", breaks=seq(0,100,5), xlim=c(0,100), ylab="Frequency of Reports", ylim=c(0,300), col="red")
hist(DS_ALL$wrkADJDSI, main="Adjusted Reported DSI", xlab="Reported aDSI", breaks=seq(0,100,5), xlim=c(0,100), ylab="Frequency of Reports", ylim=c(0,300),col="green")
hist(DS_ALL$wrkDIFDSI, main="Difference between DSI and aDSI", xlab="Reported DSI-aDSI", breaks=seq(0,100,5), xlim=c(0,100), ylab="Frequency of Reports", ylim=c(0,400), col="yellow")

# Simple Horizontal Bar Plot with Added Labels for plagarism levels. 
counts <- table(DS_ALL$wrkCOALVL)
barplot(counts, main="Membership in Document Similarity Levels", horiz=TRUE, xlab = "Documents", xlim=c(0,700), names.arg=c("L1: 0-14%", "L2: 15%-24%", "L3: 25%-100%"), col=c("Green","yellow","Red"))

###############################################################################
# Simple Histograms visually examining normality (Skewness and Kurtosis).
hist(DS_DIS$dcmGRSDSI, main="Turnitin Reported DSI", xlab="Reported DSI", breaks=seq(0,100,5), xlim=c(0,100), ylab="Frequency of Reports", ylim=c(0,150), col="red")
hist(DS_DIS$wrkADJDSI, main="Adjusted Reported DSI", xlab="Reported aDSI", breaks=seq(0,100,5), xlim=c(0,100), ylab="Frequency of Reports", ylim=c(0,150),col="green")
hist(DS_DIS$wrkDIFDSI, main="Difference between DSI and aDSI", xlab="Reported DSI-aDSI", breaks=seq(0,100,5), xlim=c(0,100), ylab="Frequency of Reports", ylim=c(0,250), col="yellow")

# Simple Horizontal Bar Plot with Added Labels for plagarism levels. 
counts <- table(DS_DIS$wrkCOALVL)
barplot(counts, main="Membership in Document Similarity Levels", horiz=TRUE, xlab = "Documents", xlim=c(0,360), names.arg=c("L1: 0-14%", "L2: 15%-24%", "L3: 25%-100%"), col=c("Green","yellow","Red"))

###############################################################################
# Simple Histograms visually examining normality (Skewness and Kurtosis).
hist(DS_ART$dcmGRSDSI, main="Turnitin Reported DSI", xlab="Reported DSI", breaks=seq(0,100,5), xlim=c(0,100), ylab="Frequency of Reports", ylim=c(0,150), col="red")
hist(DS_ART$wrkADJDSI, main="Adjusted Reported DSI", xlab="Reported aDSI", breaks=seq(0,100,5), xlim=c(0,100), ylab="Frequency of Reports", ylim=c(0,150),col="green")
hist(DS_ART$wrkDIFDSI, main="Difference between DSI and aDSI", xlab="Reported DSI-aDSI", breaks=seq(0,100,5), xlim=c(0,100), ylab="Frequency of Reports", ylim=c(0,250), col="yellow")

# Simple Horizontal Bar Plot with Added Labels for plagarism levels. 
counts <- table(DS_ART$wrkCOALVL)
barplot(counts, main="Membership in Document Similarity Levels", horiz=TRUE, xlab = "Documents", xlim=c(0,360), names.arg=c("L1: 0-14%", "L2: 15%-24%", "L3: 25%-100%"), col=c("Green","yellow","Red"))

###############################################################################
library(nnet); library(reshape2); library(knitr); library(ggplot2)

plot(DS_ALL$wrkADJDSI, DS_ALL$dcmDOCCLS, main="Research Method Scatterplot", xlab="ADJ DSI ", ylab="Research Method ")
abline(lm(DS_ALL$dcmDOCCLS~DS_ALL$wrkADJDSI), col="red") # regression line (y~x) 

plot(DS_ALL$wrkADJDSI, DS_ALL$dcmWRDCNT, main="Word Count Scatterplot", xlab="ADJ DSI ", ylab="WRD CNT ")
abline(lm(DS_ALL$dcmWRDCNT~DS_ALL$wrkADJDSI), col="red") # regression line (y~x) 

plot(DS_ALL$wrkADJDSI, DS_ALL$dcmREFCNT, main="Reference Count Scatterplot", xlab="ADJ DSI ", ylab="REF CNT ")
abline(lm(DS_ALL$dcmREFCNT~DS_ALL$wrkADJDSI), col="red") # regression line (y~x) 

###############################################################################
plot(DS_DIS$wrkADJDSI, DS_DIS$dcmDOCCLS, main="Research Method Scatterplot", xlab="ADJ DSI ", ylab="Research Method ")
abline(lm(DS_DIS$dcmDOCCLS~DS_DIS$wrkADJDSI), col="red") # regression line (y~x) 

plot(DS_DIS$wrkADJDSI, DS_DIS$dcmWRDCNT, main="Word Count Scatterplot", xlab="ADJ DSI ", ylab="WRD CNT ")
abline(lm(DS_DIS$dcmWRDCNT~DS_DIS$wrkADJDSI), col="red") # regression line (y~x) 

plot(DS_DIS$wrkADJDSI, DS_DIS$dcmREFCNT, main="Reference Count Scatterplot", xlab="ADJ DSI ", ylab="REF CNT ")
abline(lm(DS_DIS$dcmREFCNT~DS_DIS$wrkADJDSI), col="red") # regression line (y~x) 

###############################################################################
plot(DS_ART$wrkADJDSI, DS_ART$dcmDOCCLS, main="Research Method Scatterplot", xlab="ADJ DSI ", ylab="Research Method ")
abline(lm(DS_ART$dcmDOCCLS~DS_ART$wrkADJDSI), col="red") # regression line (y~x) 

plot(DS_ART$wrkADJDSI, DS_ART$dcmWRDCNT, main="Word Count Scatterplot", xlab="ADJ DSI ", ylab="WRD CNT ")
abline(lm(DS_ART$dcmWRDCNT~DS_ART$wrkADJDSI), col="red") # regression line (y~x) 

plot(DS_ART$wrkADJDSI, DS_ART$dcmREFCNT, main="Reference Count Scatterplot", xlab="ADJ DSI ", ylab="REF CNT ")
abline(lm(DS_ART$dcmREFCNT~DS_ART$wrkADJDSI), col="red") # regression line (y~x) 



