[R] merging data frames

jim holtman jholtman at gmail.com
Mon Jun 14 18:36:12 CEST 2010


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?



More information about the R-help mailing list