Last active
June 29, 2020 16:24
-
-
Save kumeS/edc445c37979593309b3598495bacf2f to your computer and use it in GitHub Desktop.
Data form and Basic Statistics (DBS)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Data form and Basic Statistics (DBS) | |
# PDF output of pairs.panelsR plot | |
if(!require("psych")){install.packages("psych")} | |
library(psych) | |
dbs <- function(x, PDFfile=T){ | |
set.seed(125) | |
dfx <- as.data.frame(x) | |
message( "####################" ) | |
message( "head(x)" ) | |
message( "####################" ) | |
print(head(dfx)) | |
Sys.sleep(1) | |
message( "####################" ) | |
message( "dimnames(x)" ) | |
message( "####################" ) | |
print(dimnames(dfx)) | |
Sys.sleep(1) | |
message( "####################" ) | |
message( "dim(x)" ) | |
message( "####################" ) | |
print(dim(dfx)) | |
Sys.sleep(1) | |
message( "####################" ) | |
message( "str(x)" ) | |
message( "####################" ) | |
str(dfx) | |
Sys.sleep(1) | |
message( "####################" ) | |
message( "## summary(x)" ) | |
message( "####################" ) | |
print(summary(dfx)) | |
Sys.sleep(1) | |
message( "####################" ) | |
message( "## the PDF output of pairs.panelsR plot" ) | |
message( "####################" ) | |
dfA <- dfx[, sapply(dfx, class) == "numeric"] | |
dfAc <- kmeans(dfA, centers=4, iter.max = 500, nstart = 1)$cluster | |
if(PDFfile){ | |
pdf("pairs.panelsR_output.pdf", | |
width = 1.5*ncol(dfA), height = 1.5*ncol(dfA)) | |
} | |
pairs.panelsR(dfA, | |
gap=0.5, | |
col1=adjustcolor(c('red', 'blue', 'green', "yellow4"), alpha.f=1/4)[dfAc], | |
bg=adjustcolor(c('red', 'blue', 'green', "yellow4"), alpha.f=1/6)[dfAc], | |
hist.col = adjustcolor("#00AFBB", alpha.f=1/4), | |
label.pos=0.85, | |
labels=colnames(dfx), cex.labels=1, | |
ellipses = F, | |
density = T) | |
if(PDFfile){dev.off()} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment