Nanami 13
2011-Jun-27 22:01 UTC
[R] create a new data frame after comparing two columns of the previous data frame
Hi everyone, I am trying to find a way to filter a table; If I am given for example the following table:> head(intra)chr miRNA start end strand ACC hsa_ID region region_start region_end gene_id transcrip_id 1 chr1 miRNA 1102484 1102578 + ACC="MI0000342"; ID="hsa-mir-200b"; exon 1102484 1102578 NR_029639 NR_029639 2 chr1 miRNA 1103243 1103332 + ACC="MI0000737"; ID="hsa-mir-200a"; exon 1103243 1103332 NR_029834 NR_029834 3 chr1 miRNA 1104385 1104467 + ACC="MI0001641"; ID="hsa-mir-429"; exon 1104385 1104467 NR_029957 NR_029957 4 chr1 miRNA 3044539 3044599 + ACC="MI0015861"; ID="hsa-mir-4251"; exon 3044539 3044599 NR_036215 NR_036215 5 chr1 miRNA 3477260 3477354 - ACC="MI0003556"; ID="hsa-mir-551a"; exon 3477260 3477354 NR_030277 NR_030277 6 chr1 miRNA 6489894 6489956 - ACC="MI0015864"; ID="hsa-mir-4252"; exon 6489894 6489956 NR_036218 NR_036218 I would only like to keep in the table the rows that have intra$start !intra$region_start and intra$end != intra$region_end. I've tried using this but I get the following error:> intra<- intra[(intra$start != intra$region_start )&&(intra$end !intra$region_end)] > head(intra)data frame with 0 columns and 6 rows Thank you, best, Nanami [[alternative HTML version deleted]]
jim holtman
2011-Jun-27 22:56 UTC
[R] create a new data frame after comparing two columns of the previous data frame
Use "&" instead of "&&" On Mon, Jun 27, 2011 at 6:01 PM, Nanami 13 <deconstructed.morning at gmail.com> wrote:> Hi everyone, > > I am trying to find a way to filter a table; If I am given for example the > following table: >> head(intra) > ? chr miRNA ? start ? ? end strand ? ? ? ? ? ? ?ACC ? ? ? ? ? ? hsa_ID > region region_start region_end ? gene_id transcrip_id > 1 chr1 miRNA 1102484 1102578 ? ? ?+ ACC="MI0000342"; ID="hsa-mir-200b"; > exon ? ? ?1102484 ? ?1102578 NR_029639 ? ?NR_029639 > 2 chr1 miRNA 1103243 1103332 ? ? ?+ ACC="MI0000737"; ID="hsa-mir-200a"; > exon ? ? ?1103243 ? ?1103332 NR_029834 ? ?NR_029834 > 3 chr1 miRNA 1104385 1104467 ? ? ?+ ACC="MI0001641"; ?ID="hsa-mir-429"; > exon ? ? ?1104385 ? ?1104467 NR_029957 ? ?NR_029957 > 4 chr1 miRNA 3044539 3044599 ? ? ?+ ACC="MI0015861"; ID="hsa-mir-4251"; > exon ? ? ?3044539 ? ?3044599 NR_036215 ? ?NR_036215 > 5 chr1 miRNA 3477260 3477354 ? ? ?- ACC="MI0003556"; ID="hsa-mir-551a"; > exon ? ? ?3477260 ? ?3477354 NR_030277 ? ?NR_030277 > 6 chr1 miRNA 6489894 6489956 ? ? ?- ACC="MI0015864"; ID="hsa-mir-4252"; > exon ? ? ?6489894 ? ?6489956 NR_036218 ? ?NR_036218 > > I would only like to keep in the table the rows that have intra$start !> intra$region_start and intra$end != intra$region_end. > I've tried using this but I get the following error: > > >> intra<- intra[(intra$start != intra$region_start )&&(intra$end !> intra$region_end)] >> head(intra) > data frame with 0 columns and 6 rows > > Thank you, > > best, > Nanami > > ? ? ? ?[[alternative HTML version deleted]] > > ______________________________________________ > R-help at r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. >-- Jim Holtman Data Munger Guru What is the problem that you are trying to solve?
Possibly Parallel Threads
- GV98 adapter, experience with nouveau
- [PATCH 3/4] nouveau_hwmon: migrate to hwmon_device_register_with_info
- [Bug 106305] Can't change screen brightness on MSI GT73VR with nouveau driver
- [Bug 106794] New: Driver crash while browsing with chrome
- [PATCH 14/24] drm/nouveau: Merge pre/postclose hooks