[R] Error in var(x, na.rm = na.rm) : no complete element pairs
Carlos Morales
carlosmoralesdiego at yahoo.es
Thu Mar 5 12:21:03 CET 2009
Hello,
I still have the same error which I have written in the Subject field, I leave here the code and I hope you can help me with this:
filter.clones<-function(zz.info,crom.info)
{
clones.info<-zz.info
cat("Removing clones which has a flag minor than 0\n")
ord <- order(clones.info$Flags)
clones.info<- clones.info[ ord, ]
#for(j in 1:nrow(clones.info))
#{
del<-0
#print(j)
del<-which(as.numeric(clones.info$Flags)<0)
if (length(del)!=0)
{
#print(j)
clones.info<-clones.info[-del,]
#eliminados.info<-clones.info[del,]
#if(j==1)
#{
# j<-0
#}
}
#}
##Eliminar levaduras, moscas etc
#for(j in 1:nrow(clones.info))
#{
del1<-0
del1<-grep("mix",clones.info$Name)
if (length(del1)!=0)
{
# print(j)
clones.info<-clones.info[-del1,]
}
#}
#for(j in 1:nrow(clones.info))
#{
del2<-0
del2<-grep("fly",clones.info$Name)
if (length(del2)!=0)
{
# print(j)
clones.info<-clones.info[-del2,]
}
#}
#for(j in 1:nrow(clones.info))
#{
del3<-0
del3<-grep("pombe",clones.info$Name)
if (length(del3)!=0)
{
# print(j)
clones.info<-clones.info[-del3,]
}
#}
#for(j in 1:nrow(clones.info))
#{
del4<-0
del4<-grep("DMSO",clones.info$Name)
if (length(del4)!=0)
{
# print(j)
clones.info<-clones.info[-del4,]
}
#}
#Eliminar los clones que estan unidos por un + o un menos
#for(j in 1:nrow(clones.info))
#{
del5<-0
del5<-grep("[+]",clones.info$Name)
if (length(del5)!=0)
{
# print(j)
clones.info<-clones.info[-del5,]
}
#}
#for(j in 1:nrow(clones.info))
#{
del6<-0
del6<-grep("[-]",clones.info$Name)
if(length(del6)!=0)
{
# print(j)
clones.info<-clones.info[-del6,]
}
#}
#for(j in 1:nrow(clones.info))
#{
del7<-0
del7<-grep("rep",clones.info$Name)
if(length(del7)!=0)
{
# print(j)
clones.info<-clones.info[-del7,]
}
#}
del8<-0
del8<-grep("REP",clones.info$Name)
if(length(del8)!=0)
{
# print(j)
clones.info<-clones.info[-del8,]
}
#cat("Numero de clones:",NROW(clones.info$Name),"\n")
#chroms.info<-croms.info(PruebaDefinitiva.obj)
#cat("Reordering the chromosomes\n")
#ord <- order(chroms.info$picked_off_as_SI_name)
#chroms.info<- chroms.info[ ord, ]
#ord <- order(PruebaDefinitiva.obj$crom.info$picked_off_as_SI_name)
##crom.info <- crom.info[ ord, ]
nrow(clones.info)
#a<-PruebaDefinitiva.obj$zz.info
#PruebaDefinitiva.obj$zz.info<-0
#PruebaDefinitiva.obj$zz.info<-clones.info
#PruebaDefinitiva.obj$zz.info
clones.info
cat("Reordering the chromosomes\n")
ord <- order(crom.info$picked_off_as_SI_name)
crom.info<- crom.info[ ord, ]
#arch.info<-cbind(arch.info,000)
#names(arch.info)[NCOL(arch.info)]<-"Cromosomas"
clones2.info<-clones.info
clones2.info<-cbind(clones2.info,000)
names(clones2.info)[NCOL(clones2.info)]<-"Cromosomas"
clones2.info
##Añadir columna con los cromosomas
#ncol(arch.info)
#arch.info<-arch.info
#arch.info<-cbind(arch.info,000)
#names(arch.info)[NCOL(arch.info)]<-"Cromosomas"
ord <- order(clones2.info$Name)
clones2.info<- clones2.info[ ord, ]
for(i in 1:nrow(clones2.info))
{
cat("Processing clon ",i,"\n")
find<-match(clones2.info$Name[i],crom.info$picked_off_as_SI_name,nomatch=0)
print(find)
if((length(find)!=0) &&(find!=0))
{
clones2.info$Cromosomas[i]<-paste(crom.info$current_chromosome[find])
}
find<-0
}
del1<-0
del1<-grep("X",clones2.info$Cromosomas)
if (length(del1)!=0)
{
# print(j)
clones2.info<-clones2.info[-del1,]
}
del1<-0
del1<-grep("Y",clones2.info$Cromosomas)
if (length(del1)!=0)
{
# print(j)
clones2.info<-clones2.info[-del1,]
}
del1<-0
del1<-grep("Un_",clones2.info$Cromosomas)
if (length(del1)!=0)
{
# print(j)
clones2.info<-clones2.info[-del1,]
}
del1<-0
del1<-grep("DR",clones2.info$Cromosomas)
if (length(del1)!=0)
{
# print(j)
clones2.info<-clones2.info[-del1,]
}
ord <- order(clones2.info$Cromosomas)
clones2.info<- clones2.info[ ord, ]
count<-0
for(j in 1:nrow(clones2.info))
{
nchar(clones2.info$Cromosomas[j])
if(nchar(clones2.info$Cromosomas[j])==0)
{
count<-count+1
#b<-j
#arch2.info<-arch2.info[-j,]
}
#j<-b
}
for(j in (count+1):nrow(clones2.info))
{
clones2.info[j-count,]<-clones2.info[j,]
}
del<-0
del<-which(clones2.info$Cromosomas==0)
if (length(del)!=0)
{
#print(j)
clones2.info<-clones2.info[-del,]
#if(j==1)
#{
# j<-0
#}
}
#for(j in 1:nrow(arch2.info))
#{
# del<-0
# del<-pmatch("0",arch2.info$Cromosomas[j])
# if((del!=0)&&(length(del)!=0))
# {
# a<-j
# arch2.info<-arch2.info[-del,]
# }
# j<-a
#}
clones2.info
tablesnew.info<-clones2.info
Log<-paste(tablesnew.info[,70])
Log
cat("Hola holita\n")
x<-median(as.numeric(Log),na.rm=TRUE)
tablesnew.info<-cbind(tablesnew.info,0)
cat("Hola holita\n")
names(tablesnew.info)[NCOL(tablesnew.info)]<-"LogminusMediana"
for(i in 1:nrow(tablesnew.info))
{
tablesnew.info$LogminusMediana[i]<-as.numeric(as.character(Log[i]))-x
}
finder<-grep(-x,tablesnew.info$LogminusMediana)
tablesnew.info$LogminusMediana[finder]<-as.character(NA)
tablesnew.info
triplicadclones.info<-data.frame(paste(tablesnew.info$Name))
names(triplicadclones.info)[1]<-"Name"
tripliclones.info<-data.frame(paste(levels(triplicadclones.info$Name)))
names(tripliclones.info)[1]<-"Name"
tripliclones.info<-cbind(tripliclones.info,000)
names(tripliclones.info)[2]<-"LogminusMediana1"
tripliclones.info<-cbind(tripliclones.info,000)
names(tripliclones.info)[3]<-"LogminusMediana2"
tripliclones.info<-cbind(tripliclones.info,000)
names(tripliclones.info)[4]<-"LogminusMediana3"
cat("Donde coños esta el error\n")
i<-1
s<-1
del<-0
for(i in 1:nrow(tripliclones.info))
{
cat(i)
d<-tripliclones.info$Name[i]
del<-grep(d,tablesnew.info$Name)
#print(del)
#print(nrow(del))
for(c in 1:NROW(del))
{
tripliclones.info[i,c+1]<-tablesnew.info$LogminusMediana[del[c]]
}
}
cat("Estoy aqui")
del<-grep("V",names(tripliclones.info))
if(length(del)!=0)
{
tripliclones.info<-tripliclones.info[,-del]
}
cat("Y aqui")
tripliclones.info
j<-0
c<-0
d<-0
eliminados<-0
for(i in 1:NROW(tripliclones.info))
{
for(j in 2:4)
{
if(is.na(tripliclones.info[i,j]))
{
c<-c+1
}
}
if(c>=2)
{
d<-d+1
eliminados[d]<-i
#gain.info<-gain.info[-i,]
c<-0
}
c<-0
}
cat("Hola intentando arreglar")
tripliclones.info<-cbind(tripliclones.info,000)
names(tripliclones.info)[5]<-"Estandar_desviation"
for(i in 1:NROW(tripliclones.info))
{
de<-0
s[1]<-0
s[2]<-0
s[3]<-0
sumatorio<-0
for(c in 1:3)
{
s[c]<-as.numeric(tripliclones.info[i,c+1])
}
cat(s)
cat(i)
de<-sd(s,na.rm=TRUE)
tripliclones.info$Estandar_desviation[i]<-de
}
tripliclones.info
}
The mistake is in de<-sd(s,na.rm=TRUE). Why?. Thanks so much from Spain
More information about the R-help
mailing list