首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >我正在使用:R x64,并且不能运行我的代码,我不知道是什么问题

我正在使用:R x64,并且不能运行我的代码,我不知道是什么问题
EN

Stack Overflow用户
提问于 2020-10-16 00:59:12
回答 1查看 27关注 0票数 0

我正在使用:R x64,并且不能运行我的代码,我不知道是什么问题。嗨,开发人员,这是我的代码,我有错误,我不知道是什么问题:

代码语言:javascript
复制
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)

以下是错误代码:

代码语言:javascript
复制
 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 
EN

回答 1

Stack Overflow用户

发布于 2020-10-16 04:08:48

这是正确的代码,非常感谢:

代码语言:javascript
复制
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 5
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/64376424

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档