Skip to content
Prev 205198 / 398506 Next

caculate the frequencies of the Amino Acids

che
Thanks very much the code is working perfectly, but I hope guys that you can
help me to do the same thing but by using the loop structure, i want to know
if i am doing right, i want to use the loop structure to scan each sequence
from the file sequence.txt (the file is attached) to get the frequency for
each Amino Acid, and i wrote the following code so far, and i stopped, got
confused, specially that i am a very beginner in R
http://n4.nabble.com/file/n997581/sequence.txt sequence.txt :
x<-read.table("sequence.txt",header=FALSE)
AA<-c('A','C','D','E','F','G','H','I','K','L','M','N','P','Q','R','S','T','V','W','Y')

test<-nchar(as.character(x$V1[i]))
frequency<-function(X)
{
y<-rep(0,20)
for(j in 1:test){
for(i in 1:nrow(x)){
	res<-which(AA==substr(x$V1[i],j,j))
	y[res]=y[res]+1
	}
	}
return(y)
}
So how to fix this code, how to give the life for the ?i? and the ?j? in
order to initiate the indexing..... Sorry for bothering you guys.
che wrote: