[R] create a new data frame after comparing two columns of the previous data frame
jim holtman
jholtman at gmail.com
Tue Jun 28 00:56:52 CEST 2011
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?
More information about the R-help
mailing list