[R] numeric(0)
dax42
Dax42 at web.de
Wed Dec 29 14:17:35 CET 2004
Dear all,
I am trying to calculate a score for a string sequence consisting of
the following four letters: ACGT.
I have got a matrix giving the scores for each pair of letters.
So for example the string ACCT has got the pairs: AC, CC and CT.
The matrix has got the following form:
names<-c("A","C","G","T");
mscore<-matrix(0,4,4);
rownames(mscore)<-names;
colnames(mscore)<-names;
So for the first example pair above I could get the score contained in
the matrix with the following code:
>> mscore["A","C"]
I am now trying to sum up all the scores with the following code:
score<-0;
for(j in 1:length(sequence)-1){
score<-score+mscore[sequence[j],sequence[j+1]];
}
where sequence is the string sequence.
Unfortunately, it does not work and I get the following error message:
Error in "[<-"(`*tmp*`, 1, i, value = numeric(0)) :
nothing to replace with
What does this mean? Strangely, the command
"print(score+mscore[sequence[j],sequence[j+1]])"
works, so it really is the assignment which won't work. Why is that?
I am running R 2.0 series (GUI version) on Mac OSX 10.3.7.
Any suggestions are welcome.
Thanks a lot,
Dax
More information about the R-help
mailing list