define a variable of type list of different lengths
hi How can define a variable of type list of different lengths? and how can define n different xS in the for loop? for example
xS in for loop
library(seqinr)
x1=read.fasta("dbppt.fasta", seqtype="AA")
library(protr)
x2=getSequence(x1)
s=matrix(data = NA, nrow = 31012, ncol = 1, byrow = FALSE,dimnames = NULL)
for(n in 1:31012) {
s[n]= c2s(x2[[n]])
}
for(n in 1:31012){
xS=protseg(s[n] , aa="S", k=7)
}
• 1,369 views
•
link
1 answer
library(seqinr)
x1=read.fasta("dbppt.fasta", seqtype="AA")
library(protr)
x2=getSequence(x1)
s=matrix(data = NA, nrow = 31012, ncol = 1, byrow = FALSE,dimnames = NULL)
for(n in 1:31012) {
s[n]= c2s(x2[[n]])
}
xS=list()
for(n in 1:31012){
xS[[n]]=protseg(s[n] , aa="S", k=7)
}
• 1 views
•
link
Log in to answer this question.
Simple. Don't use a for loop.