开发者

How to input Array in R

Hello please find below mentioned code. what i want is to add values to my array on the basis of certai开发者_Go百科n condition checks which i want to undertake. if the values are eligible then they should add to array otherwise they should be discarded. hwoever, I am unable to get the required array. Any help in that regard will be of great help. I am a student at University Of Exeter.

Y<-
>NODE_1
[1] GTTGGCCGAGCCCCAGGACGCGTGGTTGTTGAACCAGATCAGGTCCGGGCTCCACTGCACGTAGTCCTC

>NODE_2
[1] CCTCCGGCGGCACCACGGTCGGCGAGGCCCTCAACATCCTG GAGCGCACCGACCTGTCCACCGCGGACAAGGCCGGTTACCT
GCACCGCTACATCGAGGCCAGCCGCATCGCGTTCGCGGACC GCGGGCGCTGGGTCGGCGACCCCGCCTTCGAGGACGTACCG

>NODE_3
[1]GCCCGGCGCCTGGCCGCGGGCGAGTGGGTCGTGGACCTGCGCTCCCGGGTGGCCTTCGCCGCCGGTCACGTCGCCGGG
   TCGCTCAACTTCGAGGCCGACGGACAGCTCGCGACCTACCTGGCCTGGCTGATCCCCTGGGGCAGGCCGGTGACGCTG
   CTGGCGCACAGTGCCGACGACCTGGCCCGCGCCCAGCGCGAGCTGGCCCGGGTGGGCATCGA

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 then 30.


Perhaps I don't see exactly what you are asking for, but you could try the following.

# set up some data
Y <- list()
Y$NODE_1 <- "GTTGGCCGAGCCCCAGG"  # truncated to give example < 30
Y$NODE_2 <- "CCTCCGGCGGCACCACGTCGGCGAGGCCCTCAACATCCTGAGCGCACCGACCTGTCCACCGCGGACAAGGCCG"
Y$NODE_3 <- "CCCGGCGCCTGGCCGGGGCGAGTGGGTCGTGGACCTGCGCTCCCGGGTGGCCTTCGCCGCCGGTCACGTCGCC"
Y$NODE_4 <- "GCCCGGCGCCTG"  # another example < 30
#
b <- Y[nchar(Y) < 30]  # index directly with logical vector
b
$NODE_1
[1] "GTTGGCCGAGCCCCAGG"

$NODE_4
[1] "GCCCGGCGCCTG"
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜