'R iterations only saving the first value of a vector
Up until now I find any problem I have has been had and posted here already, but this time I'm really at a loss. I am running grep in R to look for a list of regex values in two strings, and write the ones that are exclusive to one string and not the other. The outputs are vectors, but when I loop through the vectors or even just try to save them, R is only saving the first value of the vector.
So while:
inWT = as.list(rep(0, nrow(NEBres)))
> c(setdiff(c(grep(NEBres$Recognition_Site[1], reverseComplement(bigfile$FASTA, case = "upper")),
grep(NEBres$Recognition_Site[1], bigfile$FASTA)),
c(grep(NEBres$Recognition_Site[1], reverseComplement(bigfile$m_FASTA, case = "upper")),
grep(NEBres$Recognition_Site[1], bigfile$m_FASTA))))
>[1] 86 480
if I try to save it it only saves the first value as so:
inWT[1] = c(setdiff(c(grep(NEBres$Recognition_Site[1], reverseComplement(bigfile$FASTA, case = "upper")),
grep(NEBres$Recognition_Site[1], bigfile$FASTA)),
c(grep(NEBres$Recognition_Site[1], reverseComplement(bigfile$m_FASTA, case = "upper")),
grep(NEBres$Recognition_Site[1], bigfile$m_FASTA))))
> inWT[1]
[[1]]
[1] 86
I haven't been able to manage this solution for some time now, and I'm starting to run out of solutions.
Thanks in advance!
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|