Re: [R] merging data frames

From: jim holtman <jholtman_at_gmail.com>
Date: Mon, 14 Jun 2010 12:36:12 -0400

If you want to keep only the rows that are unique in the first column then do the following:

workComb1 <- subset(workComb, !duplicated(ProbeID))

On Mon, Jun 14, 2010 at 11:20 AM, Assa Yeroslaviz <frymor_at_gmail.com> wrote:
> well, the problem is basically elsewhere. I have a data frame with
> expression data and doubled IDs in the first column (see example)
> when I want to put them into row names I get the message, that there are
> non-unique items in the data.
> So I tried with unique to delete such rows. The problem is unique doesn't
> delete all of them.
>
> I compare two data frames with their Probe IDs.
> I would like to delete all double lines with a certain probe ID independent
> from the rest of the line, as to say I would like a data frame with single
> unique idetifiers in the Probe Id column.
> merge doesn't give me that. It doesn't delete all similar line, if the line
> are not identical in the other columns it leaves them in the table.
>
> Is there a way of deleting whole the line with double Probe IDs?
>
>> workbook <- read.delim(file = "workbook1.txt", quote = "", sep = "\t")
>> GeneID <- read.delim(file = "testTable.txt", quote = "", sep = "\t")
>> workComb <- merge(workbook, GeneID, by.x = "ProbeID", by.y = "Probe.Id")
>> workComb1 <- unique(workComb)
>> write.table(workComb, file = "workComb.txt" , sep = "\t", quote = FALSE,
>> row.names = FALSE)
>> write.table(workComb1, file = "workComb1.txt" , sep = "\t", quote = FALSE,
>> row.names = FALSE)
>
> look at lines 49 and 50 in the file workComb1.txt after using unique on the
> file. The line are identical  with the exception of the Transcript ID. I
> would like to take one of them out of the table.
>
> THX,
>
> Assa
>
> On Mon, Jun 14, 2010 at 15:33, jim holtman <jholtman_at_gmail.com> wrote:
>>
>> Put the rownames as another column in your dataframe so that it
>> remains with the data.  After merging, you can then use it as the
>> "rownames"
>>
>> On Mon, Jun 14, 2010 at 9:25 AM, Assa Yeroslaviz <frymor_at_gmail.com> wrote:
>> > Hi,
>> >
>> > is it possible to merge two data frames while preserving the row names
>> > of
>> > the bigger data frame?
>> >
>> > I have two data frames which  i would like to combine. While doing so I
>> > always loose the row names. When I try to append this, I get the error
>> > message, that I have non-unique names. This although I used unique
>> > command
>> > on the data frame where the double inputs supposedly are
>> >
>> > thanks for the help
>> >
>> > Assa
>> >
>> >        [[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
>> Cincinnati, OH
>> +1 513 646 9390
>>
>> What is the problem that you are trying to solve?
>
>

-- 
Jim Holtman
Cincinnati, OH
+1 513 646 9390

What is the problem that you are trying to solve?

______________________________________________
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.
Received on Mon 14 Jun 2010 - 16:38:30 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Mon 14 Jun 2010 - 16:40:32 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive