Reputation: 1
I am trying to create a label to the combn
command so that I know exactly which pairs where compared.
Here's an example:
Let a be my vector of interest,
a<-seq(1,10,1)
c<-combn(a,2)
So I want to create a vector label with the numbers that are paired:
label<-rep("abc",times=ncol(c)) #This is just a vector to initialized "label"
head(label)
for(i in ncol(c)){
label[i]<-c(paste("Exon",c[1,i],"with",c[2,i]))
}
head(label)
The problem is when I run the for
loop it doesn't work. Alternatively, it only outputs the last comparison.
Upvotes: 0
Views: 513
Reputation: 25736
Remove the loop and use a vectorized approach:
label <- paste("Exon", c[1,] "with", c[2,])
BTW: c
is a very bad variable name (see ?c
).
Upvotes: 3