LISTSERV mailing list manager LISTSERV 16.0

Help for R-USERS-L Archives


R-USERS-L Archives

R-USERS-L Archives


R-USERS-L@LISTS.UFL.EDU


View:

Message:

[

First

|

Previous

|

Next

|

Last

]

By Topic:

[

First

|

Previous

|

Next

|

Last

]

By Author:

[

First

|

Previous

|

Next

|

Last

]

Font:

Proportional Font

LISTSERV Archives

LISTSERV Archives

R-USERS-L Home

R-USERS-L Home

R-USERS-L  2018

R-USERS-L 2018

Subject:

R question

From:

"El Rouby,Nihal M" <[log in to unmask]>

Reply-To:

UF R Users List <[log in to unmask]>

Date:

Wed, 11 Jul 2018 20:58:57 +0000

Content-Type:

text/plain

Parts/Attachments:

Parts/Attachments

text/plain (1 lines)

Dear All-

I have a data with genotype and medication exposure on repeated dates. I’m trying to table the counts of the genotypes for unique individuals in each medication group . I tried  several codes to summarize the data by genotypes and medications, but with no luck

I used summarize and group_by from dplyr

output<-d1 %>%
group_by(d1$`Med Order Display Name`,d1$`CYP2C19 Genotype`) %>% distinct(d1$`Record ID`)%>%summarise(n())

Another code I tried

with(d1, tapply(d1$`Med Order Display Name`, d1$`CYP2C19 Genotype`, FUN = function(x) length(unique(x))))

I appreciate your input on a direction I should take.



My example data is

Record ID

CYP2C19 Genotype

Med Order Display Name

3

*1/*1

pantoprazole (PROTONIX) injection 40 mg

3

*1/*1

pantoprazole (PROTONIX) injection 40 mg

3

*1/*1

pantoprazole (PROTONIX) EC tablet 40 mg

13

*1/*17

pantoprazole (PROTONIX) 40 MG Tablet Delayed Release

13

*1/*17

pantoprazole (PROTONIX) 40 MG Tablet Delayed Release

13

*1/*17

pantoprazole (PROTONIX) 40 MG tablet

13

*1/*17

pantoprazole (PROTONIX) 40 MG tablet

28

*1/*1

esomeprazole (NexIUM) capsule 20 mg

28

*1/*1

pantoprazole (PROTONIX) EC tablet 40 mg

28

*1/*1

pantoprazole (PROTONIX) 40 MG tablet

28

*1/*1

esomeprazole (NexIUM) capsule 40 mg

52

*1/*1

NEXIUM 40 MG Capsule Delayed Release

52

*1/*1

NEXIUM 40 MG Capsule Delayed Release

52

*1/*1

esomeprazole (NexIUM) 40 MG Capsule Delayed Release

52

*1/*1

NEXIUM 40 MG PO Capsule Delayed Release


I hope I can get an output like that


pantoprazole (PROTONIX) injection 40 mg

pantoprazole (PROTONIX) EC tablet 40 mg

pantoprazole (PROTONIX) 40 MG Tablet Delayed Release

pantoprazole (PROTONIX) 40 MG tablet

esomeprazole (NexIUM) capsule 20 mg

NEXIUM 40 MG Capsule Delayed Release

NEXIUM 40 MG PO Capsule Delayed Release

esomeprazole (NexIUM) 40 MG Capsule Delayed Release


*1/*2

xx

xx

xx

xx

*1/*17

xx

xx

xx

xx

*1/*2

xx

xx

xx

xx

inconclusive

xx

xx

xx

xx

*2/*2

xx

xx

xx

xx

*17/*17

xx

xx

xx

xx




This list strives to be beginner friendly.  However, we still ask that you
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Top of Message | Previous Page | Permalink

Advanced Options


Options

Log In

Log In

Get Password

Get Password


Search Archives

Search Archives


Subscribe or Unsubscribe

Subscribe or Unsubscribe


Archives

2019
2018
2017
2016
2015
2014
2013
2012
2011
2010
2009
2008

ATOM RSS1 RSS2



LISTS.UFL.EDU

CataList Email List Search Powered by the LISTSERV Email List Manager