Hi,

I am getting error while running this code:

if( datatype =="sam" )
{
#dat <- read.table(pipe(paste("cut -f3,4",file("S_57_IonXpress_001.sam"),sep=" ")), header=FALSE,colClasses= c("character","integer"))
dat <- read.table(file("stdin"), header=FALSE,colClasses= c("character","integer"))
colnames(dat)=c("refChr","begin")


dat=dat[dat$refChr!="*" & dat$refChr!="chrM" ,]
binindex = ifelse((dat$begin%%50000)==0,floor(dat$begin/50000)-1,floor(dat$begin/50000))

fastbincount = table(paste(dat$refChr,binindex, sep="_"))
newtemp=as.data.frame(matrix(NA, ncol=2, nrow=length(fastbincount)))
newtemp[,1]=paste(names(fastbincount))
newtemp[,2]=as.numeric(paste(fastbincount))
colnames(newtemp)=c("binName","counts")

}
if( datatype =="counts" )
{
newtemp <- read.table(file.name, header=FALSE,colClasses= c("character","integer"))
colnames(newtemp)=c("binName","counts")
}

bininfo = merge(bininfo, newtemp, by="binName",all.x=T)
bininfo=bininfo[order(bininfo$binorder),]

error is:

Error in if (datatype == "sam") { : missing value where TRUE/FALSE needed. 
Error in if (datatype == "counts") { : 
  missing value where TRUE/FALSE needed.
Error in as.data.frame(y) : object 'newtemp' not found

Please tell me how would I rectify this error? I couldn't understand actually. Thanks in advance



Source link