input array in R
Hello please find below mentioned code. What I want is to add values to my array on the basis of certain condition checks which I want to undertake. If the values are eligible, th开发者_如何学Pythonen they should add to array otherwise they should be discarded. However, I am unable to get the required array. Any help in that regard will be of great help.
>NODE_1
[1]GTTGGCCGAGCCCCAGGACGCGTGGTTGTTGAACCAGATCAGGTCCGGGCTCCACTGCACGTAGTCCTCTTCCCAATTTCCCTTAA
>NODE_2
[1] CCTCCGGCGGCACCACGGTCGGCGAGGCCCTCAACATCCTG GAGCGCACCGACCTGTCCACCGCGGACAAGGCCGGTTACCT
GCACCGCTACATCGAGGCCAGCCGCATCGCGTTCGCGGACC
>NODE_3
[1]GCCCGGCGCCTGGCCGCGGGCGAGTGGGTCGTGGACCTGCGCTCCCGGGTGGCCTTCGCCGCCGGTCACGTCGCCGGG
TCGCTCAACTTCGAGGCCGACGGACAGCT
My code is:
Length <- function(a)
{
b<-list()
for ( i in 1: length(a))
{
b[i]<-which(length(a[i])<30, arr.ind = FALSE, useNames = TRUE)
m<- array(b[i])
}
}
k<- Length(Y)
So what I want to do is add only those data to array b
from Y
whose length is less than 30.
you should use nchar()
instead of length()
to get the number of characters.
And to do it the R way, you could use the boolean index: k <- a[nchar(a)<30]
Hope that helps!
精彩评论