Entering edit mode
I am trying to design a matrix, but I got the following error. Please help me to understand this error.
# > design <- matrix(data=0,nrow=ncol(gene expression data), ncol=2)
> rownames(design) <- colnames(gene expression data)
> colnames(design) <- c("Carcinoma","Normal")
> cSamples <- rownames(phenodata)[grep("Tumor",HB$Condition)]
> nSamples <- rownames(phenodata)[grep("Non_neoplastic",HB$Condition)]
> design[cSamples,"Carcinoma"] <- 1
**Error in `[<-`(`*tmp*`, cSamples, "Carcinoma", value = 1) :
subscript out of bounds**
# This is my phenodata
Sample_id Condition Patient Batch
P105A Non_neoplastic P105 A
P105D Tumor P105 A
P106A Non_neoplastic P106 B
P106D Tumor P106 B
P112A Non_neoplastic P112 C
P112D Tumor P112 C
P131A Non_neoplastic P131 D
P131D Tumor P131 D
P138A Non_neoplastic P138 E
P138D Tumor P138 E
P140A Non_neoplastic P140 F
P140D Tumor P140 F
P152A Non_neoplastic P152 G
P152D Tumor P152 G
P157A Non_neoplastic P157 H
P157D Tumor P157 H
P158A Non_neoplastic P158 I
P158D Tumor P158 I
P161A Non_neoplastic P161 J
P161D Tumor P161 J
P16A Non_neoplastic P16 K
P16D Tumor P16 K
P170A Non_neoplastic P170 L
P170D Tumor P170 L
P171A Non_neoplastic P171 M
P171D Tumor P171 M
P176A Non_neoplastic P176 N
P176D Tumor P176 N
P179A Non_neoplastic P179 O
P179D Tumor P179 O
P49A Non_neoplastic P49 P
P49D Tumor P49 P
P62A Non_neoplastic P62 Q
P62D Tumor P62 Q
P6A Non_neoplastic P6 R
P6D Tumor P6 R
P75A Non neoplastic P75 S
P75D Tumor P75 S
P94A Non_neoplastic P94 T
P94D Tumor P94 T
P99A Non_neoplastic P99 U
P99D Tumor P99 U
> design <- matrix(data=0,nrow=ncol(gene expression data), ncol=2)
> rownames(design) <- colnames(gene expression data)
> colnames(design) <- c("Carcinoma","Normal")
> cSamples <- rownames(phenodata)[grep("Tumor",phenodata$Condition)]
> nSamples <- rownames(phenodata)[grep("Non_neoplastic",phenodata$Condition)]
> design[cSamples,"Carcinoma"] <- 1
Error in
[<-
(*tmp*
, cSamples, "Carcinoma", value = 1) : subscript out of boundsplease help me to sort out this error