Hi Abo,
This is essentially the same as your other problem. Notice that this
solution will only work if the values in dt1 and dt2 are character,
not factor and that I have replaced the space in "Drug name" with an
underscore. R will automatically substitute a period when such a name
is read in.
dt
Here is a solution to the "shared values" question
> library(stringr)
> input <- read.table(text = "A B
+
+ 1,2,5 3,8,7
+
+ 2,4,6 7,6,3 ",
+ header = TRUE,
+ as.is = TRUE
+ )
>
> input$'shared values' <- apply(input, 1, function(x){
+ toString(intersect(str
a table like df1 but in the order of the 1st column
> of my df2.
>
> This would be like this
>
>> joined tables
> Drug name indications
>
>
> Simvastatin hyperlipidemia
>
> losartan hypertension
>
> Ibuprofen pain
>
ext
to it under "indications" column.
From: Ulrik Stervbo
Sent: 09 May 2017 06:31 PM
To: abo dalash
Subject: Re: [R] Joining tables with different order and matched values
Hi Abo,
Please keep the list in cc - 1) the comments are accessible to every
om: Ulrik Stervbo
> Date: 09/05/2017 7:42 a.m. (GMT+00:00)
> To: abo dalash , "r-help@R-project.org" <
> r-help@r-project.org>
> Subject: Re: [R] Joining tables with different order and matched values
>
> Hi Abo,
>
> ?merge
>
> or the join functions f
Hi Abo,
?merge
or the join functions from dplyr.
HTH
Ulrik
On Tue, 9 May 2017 at 06:44 abo dalash wrote:
> Hi All ..,
>
>
> I have 2 tables and I'm trying to have some information from the 1st table
> to appear in the second table with different order.
>
>
> For Example, let's say this is my
6 matches
Mail list logo