私は R が初めてで、関数 readLines を使用して数式を作成しようとしていますが、常に R が同じエラーを返し、修正方法がわかりません。助言がありますか?
私の式
sam.cover<-function(){
readLines()->CH
gsub("00","0,0",CH)->CH
gsub("01","0,1",CH)->CH
gsub("10","1,0",CH)->CH
gsub("11","1,1",CH)->CH
gsub(" 1;","",CH)->CH
gsub("00","0,0",CH)->CH
gsub("01","0,1",CH)->CH
gsub("01","1,0",CH)->CH
gsub("11","1,1",CH)->CH
write.table(CH,"temporaryfile.txt",quo=F,sep="",row=F,col=F)
as.matrix(read.table("temporaryfile.txt",sep=","))->CH
matrix(CH,nr=dim(CH)[ 1])->CH
apply(CH,1,sum)->SUM
CF<-999
t<-dim(CH)[ 2]
for(i in 1:t){
CF<-c(CF,sum(SUM==i))
}
cat("Capture frequencies : ","\n")
print(rbind(1:i,CF[ -1])->CF)
f1<-CF[ 2,1]
f2<-CF[ 2,2]
f3<-CF[ 2,3]
cat("Sample coverage estimates : ","\n")
cat("C1-hat =",1-f1/sum(apply(CF,2,prod)),"\n")
cat("C2-hat =",1-(f1-2*f2/(t-1))/sum(apply(CF,2,prod)),"\n")
cat("C3-hat =",1-(f1-2*f2/(t-1)+6*f3/(t-1)/(t-2))/sum(apply(CF,2,prod)),"\n")
}
私のデータ
ide c1 c2 c3 c4 c5
N19 1 1 1 0 1
N29 0 0 1 1 0
N39 0 0 1 0 1
N49 0 0 0 1 1
N59 0 0 1 0 0
私のエラー:
Error in readLines(histoire.inp) : 'con' is not a connection