Академический Документы
Профессиональный Документы
Культура Документы
plotcluster(mydata2,fit$cluster)
library("MASS",
lib.loc="/Library/Frameworks/R.framework/Versions/3.3/Resou
rces/library")
clusplot(mydata2, fit$cluster, color=TRUE, shade=TRUE, labels=2,
lines=0)
library(fpc)
require(fpc)
install.packages("fpc")
plotcluster(mydata2,fit$cluster)
require(fpc)
plotcluster(mydata2,fit$cluster)
library("xlsx",
lib.loc="/Library/Frameworks/R.framework/Versions/3.3/Resou
rces/library")
mynewdata <- read.xlsx("dataset1.xlsx",SheetName = "mydataset")
mynewdata <- read.xlsx("dataset1.xlsx",sheetName = "mydataset")
View(mynewdata)
summary(mynewdata)
is.na(mynewdata)
View(mynewdata)
summary(mynewdata)
grep("^Missing", mynewdata)
View(mynewdata)
is.numeric(mynewdata$SEX)
is.numeric(mynewdata$RELIGION)
is.numeric(mynewdata$MARITAL)
is.factor(mynewdata$MARITAL)
mynewdata$MARITAL = as.numeric(mynewdata$MARITAL)
is.numeric(mynewdata)
is.factor(mynewdata$MARITAL)
is.numeric(mynewdata$MARITAL)
is.numeric(mynewdata$RACE)
is.numeric(mynewdata$DISTRICT)
is.factor(mynewdata$DISTRICT)
mynewdata$DISTRICT = as.numeric(mynewdata$DISTRICT)
is.numeric(mynewdata$DISTRICT)
is.numeric(mynewdata$OCCUPATION)
is.factor(mynewdata$OCCUPATION)
mynewdata$OCCUPATION = as.numeric(mynewdata$OCCUPATION)
summary(mynewdata)
clear
is.factor(mynewdata$OCCUPATION)
is.numeric(mynewdata$OCCUPATION)
summary(mynewdata)
mynewdata <- read.xlsx("dataset1.xlsx",sheetName = "mydataset")
library("xlsx",
lib.loc="/Library/Frameworks/R.framework/Versions/3.3/Resou
rces/library")
detach("package:xlsxjars", unload=TRUE)
library("xlsxjars",
lib.loc="/Library/Frameworks/R.framework/Versions/3.3/Resou
rces/library")
summary(mynewdata)
mynewdata <- read.xlsx("dataset1.xlsx",sheetName = "mydataset")
View(mynewdata)
summary(mynewdata)
library("xlsx",
lib.loc="/Library/Frameworks/R.framework/Versions/3.3/Resou
rces/library")
detach("package:xlsxjars", unload=TRUE)
library("xlsxjars",
lib.loc="/Library/Frameworks/R.framework/Versions/3.3/Resou
rces/library")
ls()
rm(mydata)
ls()
rm(mydata2)
mydata <- read.xlsx("dataset2.xlsx",sheetName = "mydataset")
View(mydata)
summary(mydata)
View(mydata)
is.data.frame(mydata)
mydata1 = subset(mydata, select = c("SEX", "RELIGION", "MARITAL",
"RACE", "DISTRICT",
"OCCUPATION.MAJOR.GROUP","DATE.OF.ORIGINAL.DIAGNOSIS
", "AGE.DIAGNOSED..YRS"))
mydata1 = subset(mydata, select = c(SEX, RELIGION, MARITAL, RACE,
DISTRICT,
OCCUPATION.MAJOR.GROUP,DATE.OF.ORIGINAL.DIAGNOSIS,
AGE.DIAGNOSED..YRS))
mydata1 = subset(mydata, select = c(SEX, RELIGION, MARITAL, RACE,
DISTRICT,
OCCUPATION.MAJOR.GROUP,DATE.OF.ORIGINAL.DIAGNOSIS,
AGE.DIAGNOSED..YRS.))
View(mydata1)
is.na(mydata1)
mydata1
?is.na
is.na(mydata1$MARITAL)
typeof(mydata1)
str(mydata1)
mydata1[mydata1 == 'Missing'] <- NA
mydata1[mydata1 == 'NA'] <- NA
mydata1[mydata1 == 'NA'] <- NA
ls()
rm(mydata1)
ls()
mydata1 = subset(mydata, select = c(SEX, MARITAL, RACE, DISTRICT,
OCCUPATION.MAJOR.GROUP, AGE.DIAGNOSED..YRS.))
View(mydata1)
?sapply
example("sapply")
sapply(mydata1, typeof)
str(mydata1)
is.na(mydata1)
is.na(mydata1$DISTRICT)
mydata1[mydata1 == 'NA'] = NA
is.na(mydata1$DISTRICT)
?na
?complete.cases
is.na(mydata1$MARITAL)
sum(!complete.cases((mydata1)))
which(!complete.cases((mydata1)))
mydata1[complete.cases(mydata1), ]
sum(!complete.cases((mydata1)))
which(!complete.cases((mydata1)))
mydata2 <- mydata1[complete.cases(mydata1), ]
str(mydata2)
is.na(mydata2$MARITAL)
View(mydata2)
sum(!complete.cases((mydata2)))
View(mydata1)
sum(!complete.cases((mydata1)))
View(mydata2)
sum(!complete.cases((mydata2)))
ls()
library("xlsx",
lib.loc="/Library/Frameworks/R.framework/Versions/3.3/Resou
rces/library")
library("cluster",
lib.loc="/Library/Frameworks/R.framework/Versions/3.3/Resou
rces/library")
mydataw6 <- read.xlsx("dataset2forweek6.xlsx",sheetName =
"mydatasetw6")
mydataw6 <- read.xlsx("dataset2forweek6.xlsx",sheetName =
"mydatasetw6")
mydataw6 <- read.xlsx("dataset2forweek6.xlsx",sheetName =
"mydatasetw6")
View(mydataw6)
View(mydata2)
summary(mydataw6)
mydata1w6 = subset(mydataw6, select = c(SEX, RELIGION, MARITAL,
RACE, DISTRICT,
OCCUPATION.MAJOR.GROUP,DATE.OF.ORIGINAL.DIAGNOSIS,
AGE.DIAGNOSED..YRS.))
View(mydata1w6)
is.na(mydata1w6)
is.na(mydata1w6$MARITAL)
str(mydata1w6)
mydata1w6[mydataw6 == 'NA'] <- NA
mydata1w6[mydata1w6 == 'NA'] <- NA
ls()
rm(mydata1w6)
ls()
mydata1w6 = subset(mydataw6, select = c(SEX, MARITAL, RACE,
DISTRICT, OCCUPATION.MAJOR.GROUP,
AGE.DIAGNOSED..YRS.))
View(mydata1w6)
sapply(mydata1w6, typeof)
str(mydata1w6)
is.na(mydata1w6)
is.na(mydata1w6$DISTRICT)
mydata1w6[mydata1w6 == 'NA'] = NA
?complete.cases
is.na(mydata1w6$MARITAL)
which(!complete.cases((mydata1w6)))
mydata1w6[complete.cases(mydata1w6), ]
sum(!complete.cases((mydata1w6)))
which(!complete.cases((mydata1w6)))
mydata2w6 <- mydata1w6[complete.cases(mydata1w6), ]
str(mydata2w6)
is.na(mydata2w6$MARITAL)
View(mydata2w6)
sum(!complete.cases((mydata2w6)))
View(mydata1w6)
sum(!complete.cases((mydata1w6)))
View(mydata2w6)
str(mydata2w6)
summary(mydata2w6)
mydata2w6 <- scale(mydata2w6) #standardize variables
sum(!complete.cases((mydata2w6)))
is.numeric(mydata2w6$SEX)
is.numeric(mydata2w6$MARITAL)
is.factor(mynewdata2W6$MARITAL)
is.factor(mydata2W6$MARITAL)
is.numeric(mydata2w6$MARITAL)
is.factor(mydata2w6$MARITAL)
mydata2w6$MARITAL = as.numeric(mydata2w6$MARITAL)
is.numeric(mydata2w6$MARITAL)
is.numeric(mydata2w6$RACE)
is.numeric(mydata2w6$DISTRICT)
is.factor(mydata2w6$DISTRICT)
mydata2w6$DISTRICT = as.numeric(mydata2w6$DISTRICT)
is.numeric(mydata2w6$DISTRICT)
is.numeric(mydata2w6$OCCUPATION.MAJOR.GROUP)
is.numeric(mydata2w6$AGE.DIAGNOSED..YRS.)
mydata2w6 <- scale(mydata2w6) #standardize variables
View
View(mydata2w6)
fit.km <- kmeans(mydata2w6, 3) # 3 cluster solutions
aggregate(mydata2w6,by=list(fit.km$cluster),FUN=mean) #get cluster
means
mydata2w6 <- data.frame(mydata2w6,fit.km$cluster)
fit.km$cluster
table(mydata2w6$fit.km.cluster)
View()
View(mydata2w6)
table(mydata2w6$fit.km.cluster)
table(experimentv5.1$kmeanv5.1.cluster)
clusplot(experimentv5.1, kmeanv5.1$cluster, color=TRUE,
shade=TRUE,labels=2, lines=0) #plotting cluster solutions
plotcluster(experimentv5.1, kmeanv5.1$cluster)
write.xlsx(experimentv5.1, file = "mydata2w6.xlsx", sheetName =
"experimentv5.1", append = TRUE)
experimentv5.2 <- forexperiment
kmeanv5.2 <- kmeans(experimentv5.2, 5)
aggregate(experimentv5.2,by=list(kmeanv5.2$cluster),FUN=mean)
#get cluster means
experimentv5.2 <- data.frame(experimentv5.2,kmeanv5.2$cluster)
#append cluster assignment
View(experimentv5.2)
table(experimentv5.2$kmeanv5.2.cluster)
clusplot(experimentv5.2, kmeanv5.2$cluster, color=TRUE,
shade=TRUE,labels=2, lines=0) #plotting cluster solutions
plotcluster(experimentv5.2, kmeanv5.2$cluster)
write.xlsx(experimentv5.2, file = "mydata2w6.xlsx", sheetName =
"experimentv5.2", append = TRUE)
experimentv5.3 <- forexperiment
kmeanv5.3 <- kmeans(experimentv5.3, 5)
aggregate(experimentv5.3,by=list(kmeanv5.3$cluster),FUN=mean)
#get cluster means
experimentv5.3 <- data.frame(experimentv5.3,kmeanv5.3$cluster)
#append cluster assignment
View(experimentv5.3)
table(experimentv5.3$kmeanv5.3.cluster)
clusplot(experimentv5.3, kmeanv5.3$cluster, color=TRUE,
shade=TRUE,labels=2, lines=0) #plotting cluster solutions
plotcluster(experimentv5.3, kmeanv5.3$cluster)
write.xlsx(experimentv5.3, file = "mydata2w6.xlsx", sheetName =
"experimentv5.3", append = TRUE)
experimentv5.4 <- forexperiment
kmeanv5.4 <- kmeans(experimentv5.4, 5)
aggregate(experimentv5.4,by=list(kmeanv5.4$cluster),FUN=mean)
#get cluster means
experimentv5.4 <- data.frame(experimentv5.4,kmeanv5.4$cluster)
#append cluster assignment
View(experimentv5.4)
table(experimentv5.4$kmeanv5.4.cluster)
clusplot(experimentv5.4, kmeanv5.4$cluster, color=TRUE,
shade=TRUE,labels=2, lines=0) #plotting cluster solutions
plotcluster(experimentv5.4, kmeanv5.4$cluster)
write.xlsx(experimentv5.4, file = "mydata2w6.xlsx", sheetName =
"experimentv5.4", append = TRUE)
experimentv5.5 <- forexperiment
kmeanv5.5 <- kmeans(experimentv5.5, 5)
aggregate(experimentv5.5,by=list(kmeanv5.5$cluster),FUN=mean)
#get cluster means
experimentv5.5 <- data.frame(experimentv5.5,kmeanv5.5$cluster)
#append cluster assignment
View(experimentv5.5)
table(experimentv5.5$kmeanv5.5.cluster)
clusplot(experimentv5.5, kmeanv5.5$cluster, color=TRUE,
shade=TRUE,labels=2, lines=0) #plotting cluster solutions
plotcluster(experimentv5.5, kmeanv5.5$cluster)
write.xlsx(experimentv5.5, file = "mydata2w6.xlsx", sheetName =
"experimentv5.5", append = TRUE)
experimentv5.6 <- forexperiment
kmeanv5.6 <- kmeans(experimentv5.6, 5)
aggregate(experimentv5.6,by=list(kmeanv5.6$cluster),FUN=mean)
#get cluster means
experimentv5.6 <- data.frame(experimentv5.6,kmeanv5.6$cluster)
#append cluster assignment
View(experimentv5.6)
table(experimentv5.6$kmeanv5.6.cluster)
clusplot(experimentv5.6, kmeanv5.6$cluster, color=TRUE,
shade=TRUE,labels=2, lines=0) #plotting cluster solutions
plotcluster(experimentv5.6, kmeanv5.6$cluster)
write.xlsx(experimentv5.6, file = "mydata2w6.xlsx", sheetName =
"experimentv5.6", append = TRUE)
experimentv5.7 <- forexperiment
kmeanv5.7 <- kmeans(experimentv5.7, 5)
aggregate(experimentv5.7,by=list(kmeanv5.7$cluster),FUN=mean)
#get cluster means
experimentv5.7 <- data.frame(experimentv5.7,kmeanv5.7$cluster)
#append cluster assignment
View(experimentv5.7)
table(experimentv5.7$kmeanv5.7.cluster)
clusplot(experimentv5.7, kmeanv5.7$cluster, color=TRUE,
shade=TRUE,labels=2, lines=0) #plotting cluster solutions
plotcluster(experimentv5.7, kmeanv5.7$cluster)
write.xlsx(experimentv5.7, file = "mydata2w6.xlsx", sheetName =
"experimentv5.7", append = TRUE)
plotcluster(experimentv7.4, kmeanv7.4$cluster)
write.xlsx(experimentv7.4, file = "mydata2w6c7.xlsx", sheetName =
"experimentv7.4", append = TRUE)
experimentv7.5 <- forexperiment
kmeanv7.5 <- kmeans(experimentv7.5, 7)
aggregate(experimentv7.5,by=list(kmeanv7.5$cluster),FUN=mean)
#get cluster means
experimentv7.5 <- data.frame(experimentv7.5,kmeanv7.5$cluster)
#append cluster assignment
View(experimentv7.5)
table(experimentv7.5$kmeanv7.5.cluster)
clusplot(experimentv7.5, kmeanv7.5$cluster, color=TRUE,
shade=TRUE,labels=2, lines=0) #plotting cluster solutions
plotcluster(experimentv7.5, kmeanv7.5$cluster)
write.xlsx(experimentv7.5, file = "mydata2w6c7.xlsx", sheetName =
"experimentv7.5", append = TRUE)
experimentv7.6 <- forexperiment
kmeanv7.6 <- kmeans(experimentv7.6, 7)
aggregate(experimentv7.6,by=list(kmeanv7.6$cluster),FUN=mean)
#get cluster means
experimentv7.6 <- data.frame(experimentv7.6,kmeanv7.6$cluster)
#append cluster assignment
View(experimentv7.6)
table(experimentv7.6$kmeanv7.6.cluster)
clusplot(experimentv7.6, kmeanv7.6$cluster, color=TRUE,
shade=TRUE,labels=2, lines=0) #plotting cluster solutions
plotcluster(experimentv7.6, kmeanv7.6$cluster)
write.xlsx(experimentv7.6, file = "mydata2w6c7.xlsx", sheetName =
"experimentv7.6", append = TRUE)
experimentv7.7 <- forexperiment
kmeanv7.7 <- kmeans(experimentv7.7, 7)
aggregate(experimentv7.7,by=list(kmeanv7.7$cluster),FUN=mean)
#get cluster means
experimentv7.7 <- data.frame(experimentv7.7,kmeanv7.7$cluster)
#append cluster assignment
View(experimentv7.7)
table(experimentv7.7$kmeanv7.7.cluster)
clusplot(experimentv7.7, kmeanv7.7$cluster, color=TRUE,
shade=TRUE,labels=2, lines=0) #plotting cluster solutions
plotcluster(experimentv7.7, kmeanv7.7$cluster)
write.xlsx(experimentv7.7, file = "mydata2w6c7.xlsx", sheetName =
"experimentv7.7", append = TRUE)