我正在使用:R x64,并且不能运行我的代码,我不知道是什么问题。嗨,开发人员,这是我的代码,我有错误,我不知道是什么问题:
ncix <- read.table("nci.csv", sep = ",", row.names = 1, header = TRUE)
nciy <- read.table("ncilabel.txt", header = FALSE)
dat2 <- t(ncix)
dim(ncix)
dim(dat2)
mat <- matrix(rep(0,64*6831),nrow = 64)
for (i in 1:64){
mat[i,]<-c(nciy[i,], ncix[,i])
}
data <- data.frame(mat)
View(data)
data$Y <- factor(data$X1)
levels(data$Y)<-c("BREAST", "CNS", "COLON", "K562A-repro", "K562B-repro", "LEUKEMIA", "MCF7A-
repro","MCF7D-repro","MELANOMA","NSCLC","OVARIAN", "PROSTATE", "RENAL","UNKNOWN")
data$X1<-NULL
table(data$Y)
oui <-c("BREAST", "CNS", "COLON", "LEUKEMIA", "MELANOMA", "NSCLC", "OVARIAN", "PROSTATE", "RENAL")
dat2 <- data[data$Y%in%oui,]
mat2 <- mat[data$Y%in%oui,]
res.pca =PCA(dat2, scale.unit=TRUE, quali.sup=6831, ncp=12)以下是错误代码:
res.pca =PCA(dat2, scale.unit=TRUE, quali.sup=6831, ncp=12)
Error in PCA(dat2, scale.unit = TRUE, quali.sup = 6831, ncp = 12) :
The following variables are not quantitative: X2
The following variables are not quantitative: X3
The following variables are not quantitative: X4
The following variables are not quantitative: X5
The following variables are not quantitative: X6
The following variables are not quantitative: X7
The following variables are not quantitative: X8
The following variables are not quantitative: X9
The following variables are not quantitative: X10
The following variables are not quantitative: X11
The following variables are not quantitative: X12
The following variables are not quantitative: X13
The following variables are not quantitative: X14
The following variables are not quantitative: X15
The following variables are not quantitative: X16
The following variables are not quantitative: X17
The following variables are not quantitative: X18
The following variables are not quantitative: X19
The following variables are not quantitative: X20
The following variables are 发布于 2020-10-16 04:08:48
这是正确的代码,非常感谢:
ncix <- read.table("nci.csv", sep = ",",header = TRUE,row.names = 1)
nciy <- read.table("ncilabel.txt", header = FALSE)
dat2 <- t(ncix)
dim(ncix)
dim(dat2)
mat <- matrix(rep(0,64*6831),nrow = 64)
for (i in 1:64){
mat[i,]<-c(nciy[i,], ncix[,i])
}
data <- data.frame(mat)
View(data)
data$Y <- factor(data$X1)
levels(data$Y)<-c("BREAST", "CNS", "COLON", "K562A-repro", "K562B-repro", "LEUKEMIA",
"MCF7A-repro","MCF7D-repro","MELANOMA","NSCLC","OVARIAN", "PROSTATE",
"RENAL","UNKNOWN")
data$X1<-NULL
table(data$Y)
oui <-c("BREAST", "CNS", "COLON", "LEUKEMIA", "MELANOMA", "NSCLC", "OVARIAN",
"PROSTATE", "RENAL")
dat2 <- data[data$Y%in%oui,]
mat2 <- mat[data$Y%in%oui,]
class(data$X30)
help(levels)
library(FactoMineR)
View(dat2)
class(dat2$X2)
dim(dat2)[2]
dim(dat2)[2]-1
for (i in 1:6830){
dat2[,i]<-as.numeric(dat2[,i])
}
class(dat2$X2)
res.pca =PCA(dat2,scale.unit=TRUE, quali.sup=6831, ncp=12)
plot.PCA(res.pca, axes=c(1,2), cex=0.7,habillage=6831) # axes 1 and 2
plot.PCA(res.pca, axes=c(1,3), cex=0.7,habillage=6831) # axes 1 and 3
plot.PCA(res.pca, axes=c(2,3), cex=0.7,habillage=6831) # axes 2 and 3
plot.PCA(res.pca, axes=c(1,4), cex=0.7,habillage=6831) # axes 1 and 4
plot.PCA(res.pca, axes=c(1,5), cex=0.7,habillage=6831) # axes 1 and 5https://stackoverflow.com/questions/64376424
复制相似问题