-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.Rhistory
512 lines (512 loc) · 20.6 KB
/
.Rhistory
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
df <- df %>% add_column(ID = rep(0,nrow(df)), .after = 1) #insert ID column
df$ID[1] <- 1
for (t in 2:nrow(df))
{
if ( df$SubjectID[t]!= df$SubjectID[t-1] ) {
df$ID[t] <- df$ID[t-1]+1 }
else {
df$ID[t] <- df$ID[t-1]
}
}
##--------------------- 1. make Age from year/month -----------------------##
df$AGE <- round( df$AGEYR + df$AGEMT/12, digits=1)
df$age_group <-NA
df$age_group[df$AGE< 2] <- 'infants'
df$age_group[(df$AGE >= 2) & (df$AGE< 12) ] <- 'children'
df$age_group[(df$AGE >= 12) & (df$AGE< 18)] <- 'adolescents'
df$age_group[(df$AGE >= 18)] <- 'young adults'
#Subject_amount[ length(Subject_amount) +1] <- n_distinct(df$ID)
demo_by_age_initial <- df %>% group_by(age_group) %>% summarise ( num = n_distinct(ID) )
n_distinct(df$ID)
######################### orginal data summary #######################
summary ( (df$adductlevel>=0)& (df$adductlevel < 100))
nrow(df)
summary (df$dose >=0)
nrow ( df[( is.na(df$dose) & is.na(df$DV)), ])
write_csv(df,'cleaned_data.csv', na='.' )
n_distinct(df$ID[df$adductlevel==9999])
unique(df$SubjectID [df$adductlevel==9999])
########### ----------- 1. remove ID with no dose ----------############
##---------------- 1. add EVID ------------------##
df <- df %>% add_column(EVID = rep(0,nrow(df)), .after = match("dose",names(df)) ) #insert EVID column
df$EVID <- ifelse(df$dose> 0, 1,0 )
df$EVID[is.na(df$EVID)] <- 0
n_distinct(df$ID)
nrow(df)
##-------------------1. remove rows without neither dose or DV ------------------##
df$DV <- df$adductlevel
df <- df[ !( is.na(df$dose) & is.na(df$DV)), ]
aa <- df[ ( is.na(df$dose) & is.na(df$DV)), ]
Subject_amount[ length(Subject_amount) +1] <- n_distinct(df$ID)
n_distinct(df$ID)
nrow(Odf)- nrow(df)
View(df)
df$DV <- df$adductlevel
## data cleaning and analysis of the pediatric data
##------------------------- start --------------------####
library(ggplot2)
library(readr)
library(tibble)
library(dplyr)
library(readxl)
##------------------------- read original dataset --------------------####
path <- 'O:\\G_Drive\\code\\R_Script\\0_Projects\\data_cleaning\\Copy of Group A analysis merged data for popPK-pinkedited.xlsx' # original dataset location
setwd(dirname(path)) # set working directory
if (!file.exists(path) ) {winDialog( "ok", "File Dose Not Exist") }
Odf <- read_excel (path)
n_distinct(Odf$SubjectID )
########################################################
##---------------------------------------------------##
##---------------- Part 1 ------------------##
##--------------------------------------------------##
df <- Odf
df$doseperkg <- round(df$doseperkg,1)
df$DV<- df$adductlevel # addcut level to DV
Subject_amount <- c() # computation of total subject amount in dataset
Subject_amount[ length(Subject_amount) +1] <- n_distinct(df$SubjectID)
##---------------------1. add original row number ------------######
df$original_row_NO <- seq.int(nrow(df))
df <- df[df$original_row_NO!= 1794,] # CNMA022 first dose one month early
## ------------------- 1. add individule ID from 1 2,3, no letter in ID--------------##
df <- df %>% add_column(ID = rep(0,nrow(df)), .after = 1) #insert ID column
df$ID[1] <- 1
for (t in 2:nrow(df))
{
if ( df$SubjectID[t]!= df$SubjectID[t-1] ) {
df$ID[t] <- df$ID[t-1]+1 }
else {
df$ID[t] <- df$ID[t-1]
}
}
##--------------------- 1. make Age from year/month -----------------------##
df$AGE <- round( df$AGEYR + df$AGEMT/12, digits=1)
df$age_group <-NA
df$age_group[df$AGE< 2] <- 'infants'
df$age_group[(df$AGE >= 2) & (df$AGE< 12) ] <- 'children'
df$age_group[(df$AGE >= 12) & (df$AGE< 18)] <- 'adolescents'
df$age_group[(df$AGE >= 18)] <- 'young adults'
#Subject_amount[ length(Subject_amount) +1] <- n_distinct(df$ID)
demo_by_age_initial <- df %>% group_by(age_group) %>% summarise ( num = n_distinct(ID) )
n_distinct(df$ID)
######################### orginal data summary #######################
summary ( (df$adductlevel>=0)& (df$adductlevel < 100))
nrow(df)
summary (df$dose >=0)
nrow ( df[( is.na(df$dose) & is.na(df$DV)), ])
write_csv(df,'cleaned_data.csv', na='.' )
n_distinct(df$ID[df$adductlevel==9999])
unique(df$SubjectID [df$adductlevel==9999])
## data cleaning and analysis of the pediatric data
##------------------------- start --------------------####
library(ggplot2)
library(readr)
library(tibble)
library(dplyr)
library(readxl)
##------------------------- read original dataset --------------------####
path <- 'O:\\G_Drive\\code\\R_Script\\0_Projects\\data_cleaning\\Copy of Group A analysis merged data for popPK-pinkedited.xlsx' # original dataset location
setwd(dirname(path)) # set working directory
if (!file.exists(path) ) {winDialog( "ok", "File Dose Not Exist") }
Odf <- read_excel (path)
n_distinct(Odf$SubjectID )
########################################################
##---------------------------------------------------##
##---------------- Part 1 ------------------##
##--------------------------------------------------##
df <- Odf
df$doseperkg <- round(df$doseperkg,1)
df$DV<- df$adductlevel # addcut level to DV
Subject_amount <- c() # computation of total subject amount in dataset
Subject_amount[ length(Subject_amount) +1] <- n_distinct(df$SubjectID)
##---------------------1. add original row number ------------######
df$original_row_NO <- seq.int(nrow(df))
df <- df[df$original_row_NO!= 1794,] # CNMA022 first dose one month early
## data cleaning and analysis of the pediatric data
##------------------------- start --------------------####
library(ggplot2)
library(readr)
library(tibble)
library(dplyr)
library(readxl)
##------------------------- read original dataset --------------------####
path <- 'O:\\G_Drive\\code\\R_Script\\0_Projects\\data_cleaning\\Copy of Group A analysis merged data for popPK-pinkedited.xlsx' # original dataset location
setwd(dirname(path)) # set working directory
if (!file.exists(path) ) {winDialog( "ok", "File Dose Not Exist") }
Odf <- read_excel (path)
n_distinct(Odf$SubjectID )
df <- Odf
df$doseperkg <- round(df$doseperkg,1)
df$DV<- df$adductlevel # addcut level to DV
Subject_amount <- c() # computation of total subject amount in dataset
Subject_amount[ length(Subject_amount) +1] <- n_distinct(df$SubjectID)
df$original_row_NO <- seq.int(nrow(df))
df <- df[df$original_row_NO!= 1794,] # CNMA022 first dose one month early
## data cleaning and analysis of the pediatric data
##------------------------- start --------------------####
library(ggplot2)
library(readr)
library(tibble)
library(dplyr)
library(readxl)
##------------------------- read original dataset --------------------####
path <- 'O:\\G_Drive\\code\\R_Script\\0_Projects\\data_cleaning\\Copy of Group A analysis merged data for popPK-pinkedited.xlsx' # original dataset location
setwd(dirname(path)) # set working directory
if (!file.exists(path) ) {winDialog( "ok", "File Dose Not Exist") }
Odf <- read_excel (path)
n_distinct(Odf$SubjectID )
########################################################
##---------------------------------------------------##
##---------------- Part 1 ------------------##
##--------------------------------------------------##
df <- Odf
df$doseperkg <- round(df$doseperkg,1)
df$DV<- df$adductlevel # addcut level to DV
Subject_amount <- c() # computation of total subject amount in dataset
Subject_amount[ length(Subject_amount) +1] <- n_distinct(df$SubjectID)
df$original_row_NO <- seq.int(nrow(df))
View(df)
df <- df[df$original_row_NO!= 1794,] # CNMA022 first dose one month early
## data cleaning and analysis of the pediatric data
##------------------------- start --------------------####
library(ggplot2)
library(readr)
library(tibble)
library(dplyr)
library(readxl)
##------------------------- read original dataset --------------------####
path <- 'O:\\G_Drive\\code\\R_Script\\0_Projects\\data_cleaning\\Copy of Group A analysis merged data for popPK-pinkedited.xlsx' # original dataset location
setwd(dirname(path)) # set working directory
if (!file.exists(path) ) {winDialog( "ok", "File Dose Not Exist") }
Odf <- read_excel (path)
n_distinct(Odf$SubjectID )
########################################################
##---------------------------------------------------##
##---------------- Part 1 ------------------##
##--------------------------------------------------##
df <- Odf
df$doseperkg <- round(df$doseperkg,1)
df$DV<- df$adductlevel # addcut level to DV
Subject_amount <- c() # computation of total subject amount in dataset
Subject_amount[ length(Subject_amount) +1] <- n_distinct(df$SubjectID)
##---------------------1. add original row number ------------######
df$original_row_NO <- seq.int(nrow(df))
## ------------------- 1. add individule ID from 1 2,3, no letter in ID--------------##
df <- df %>% add_column(ID = rep(0,nrow(df)), .after = 1) #insert ID column
df$ID[1] <- 1
for (t in 2:nrow(df))
{
if ( df$SubjectID[t]!= df$SubjectID[t-1] ) {
df$ID[t] <- df$ID[t-1]+1 }
else {
df$ID[t] <- df$ID[t-1]
}
}
##--------------------- 1. make Age from year/month -----------------------##
df$AGE <- round( df$AGEYR + df$AGEMT/12, digits=1)
df$age_group <-NA
df$age_group[df$AGE< 2] <- 'infants'
df$age_group[(df$AGE >= 2) & (df$AGE< 12) ] <- 'children'
df$age_group[(df$AGE >= 12) & (df$AGE< 18)] <- 'adolescents'
df$age_group[(df$AGE >= 18)] <- 'young adults'
#Subject_amount[ length(Subject_amount) +1] <- n_distinct(df$ID)
demo_by_age_initial <- df %>% group_by(age_group) %>% summarise ( num = n_distinct(ID) )
n_distinct(df$ID)
######################### orginal data summary #######################
summary ( (df$adductlevel>=0)& (df$adductlevel < 100))
nrow(df)
summary (df$dose >=0)
nrow ( df[( is.na(df$dose) & is.na(df$DV)), ])
write_csv(df,'cleaned_data.csv', na='.' )
n_distinct(df$ID[df$adductlevel==9999])
unique(df$SubjectID [df$adductlevel==9999])
########### ----------- 1. remove ID with no dose ----------############
##---------------- 1. add EVID ------------------##
df <- df %>% add_column(EVID = rep(0,nrow(df)), .after = match("dose",names(df)) ) #insert EVID column
df$EVID <- ifelse(df$dose> 0, 1,0 )
df$EVID[is.na(df$EVID)] <- 0
n_distinct(df$ID)
nrow(df)
##-------------------1. remove rows without neither dose or DV ------------------##
df$DV <- df$adductlevel
df <- df[ !( is.na(df$dose) & is.na(df$DV)), ]
Subject_amount[ length(Subject_amount) +1] <- n_distinct(df$ID)
n_distinct(df$ID)
nrow(Odf)- nrow(df)
## ----------- 1. remove ID with no dose ----------############
remove_No_dose <- function (df) {
if ( all(df$EVID == 0) ) {
df$original_row_NO <- 999999 }
return(df)
}
df <- df %>% group_by(ID) %>% do( remove_No_dose(.))
df1 <- df [df$original_row_NO!=999999,]
setdiff( unique(Odf$SubjectID),unique(df1$SubjectID))
### ----------- 1. no DV after first dose ----------############
### input table has least one ID
remove0DV <- function (df) {
firstEVID <- which(df$EVID==1)[1] # first EVID row number
df2 <- df[(firstEVID+1):nrow(df),] # rows bigger than first evid
if ( all(is.na(df2$DV)) ) {
df$original_row_NO <- 999999 # remove this line
return(df)
} else { return (df)
}
}
df2 <- df1 %>% group_by(ID) %>% do( remove0DV(.))
df2 <- df2 [df2$original_row_NO!=999999,]
nrow(df1) - nrow(df2)
setdiff( unique(df1$SubjectID),unique(df2$SubjectID))
Total_removedID <- setdiff( unique(df$SubjectID),unique(df2$SubjectID))
df[df$SubjectID %in% Total_removedID, ] %>% group_by(age_group) %>% summarise ( num = n_distinct(ID) )
n_distinct(df2$ID)
nrow(Odf)- nrow(df2)
nrow(df) - nrow(df2)
##----------------- 5. Add time --------------------------------##
df2$Time <- df2$Time *24
df2$Time <- round(df2$Time,3)
df2 <- as.data.frame(df2)
df2 <- df2 %>% add_column(TIME = rep(NA,nrow(df2)), .after = match("time",names(df2))) #insert ID column
addtime <- function (df) {
a <- which(df$dose>0)[1]
df$TIME[a] <- 0
for (n in seq(a, (nrow(df)-1) ) ) {
df$TIME[n+1]<- df$TIME[n] + df$Time[n+1]- df$Time[n]
}
df$TIME[is.na(df$TIME)] <- c(-1)
return (df)
}
df2 <- df2 %>% group_by(ID) %>% do(addtime(.))
n_distinct(df2$ID)
###################### make redundant baseline ##############################
baseline_clean <- function (tb) {
if ( nrow ( tb[tb$TIME==-1, ] )>=2 ) { # more than one minus
dose_row <- which(tb$TIME==0)
tb$predoseDV[1:(dose_row-2)] <- 'extrabase'
return (tb)
} else {
cat ( 'ID',unique(tb$ID),'\n' )
return (tb)}
}
df2$predoseDV <- NA
df3 <- df2 %>% group_by(ID) %>% do( baseline_clean(.))
write_csv(df3,'test.csv')
n_distinct(df3$ID)
nrow(df2)- nrow(df3)
nrow(df3[df3$TIME==-1,])
n_distinct (df3$ID[df3$TIME==-1])
df3 %>% group_by(age_group) %>% summarise ( num = n_distinct(ID) )
nrow(Odf)-nrow(df3)
summary(df3[ df3$DV >=0, ] )
summary (df3$adductlevel>=0)
summary (df3$dose >=0)
ddd <- df3[ ( is.na(df3$dose) & is.na(df3$DV)), ]
###############################################################
##################### plot baseline ###############################
################ plot before conversion ###############
plotdf<- df3[(df3$TIME==-1),]
plotdf$SubjectID[plotdf$DV<0.005] <- NA
ggplot( plotdf,aes(x=ID,y=DV))+ geom_point()+
xlab(" Subject ID") +
ylab('APAP-adduct (nmol/ml)') +
ggtitle('Adduct Baseline') +
theme(plot.title = element_text(hjust = 0.5))+
geom_text (aes (label=SubjectID), size=2,hjust=-0.2,vjust=2)+
geom_hline(yintercept = c(0.03),linetype='dashed',colour = "red", size = 1) + geom_hline(yintercept = c(0.006),linetype='solid',colour = "red", size = 1,alpha=0.5) +
scale_y_continuous(limits=c(0, 0.037), breaks=seq(0,0.04, by = 0.005) )
################ plot aftter conversion ###############
plotdf2 <- df3[(df3$TIME==-1),]
plotdf2$DV[plotdf2$DV<(0.03*0.2)] <- 0
ggplot( plotdf2, aes(x=DV)) +
geom_histogram()+
ggtitle('Baseline after Conversion') +
ylab('Number of Subjects')+
theme(plot.title = element_text(hjust = 0.5))+
ylim(0,80) +
geom_vline(xintercept = c(0.03),linetype='dashed',colour = "red", size = 1) + geom_vline(xintercept = c(0.006),linetype='solid',colour = "red", size = 1,alpha=0.5) +
scale_x_continuous(name = "APAP-adduct (nmol/ml)", limits=c(-0.001, 0.037), breaks=seq(0,0.04, by = 0.005) )
###-----------2. remove the last dosing record -------- ##########
remove_last_dosing <- function (grouped_ID) {
if ( !is.na(tail(grouped_ID$DV,1)) ) { #last records is missming
return (grouped_ID)
} else {
grouped_ID <- grouped_ID[-nrow(grouped_ID),]
remove_last_dosing (grouped_ID) # recursion
}
}
df4 <- df3 %>% group_by(ID) %>% do (remove_last_dosing(.))
nrow(df3) - nrow(df4)
# xxx <- setdiff(df3,df4)
n_distinct(df4$ID)
summary(df4$DV >=0)
summary (df4$dose>=0)
################## add dose column dv row ###############
pattern <- function(df) {
n <- 1
fulldf<- list()
df$last_dose <- NA
df$last_doseperkg <- NA
for (t in 1:nrow(df)) {
if ( !is.na(df$dose[t]) & !is.na(df$DV[t+1]) ) {
df$TIME[t+1] <- df$TIME[t+1] - df$TIME[t]
df$last_dose[t+1] <- df$dose[t]
df$last_doseperkg[t+1] <- df$doseperkg[t]
df$dosageform[t+1] <- df$dosageform[t]
df$TIME[t]<- 0
fulldf[[n]] <- df[(t:(t+1)),]
n <- n+1
}
}
return ( bind_rows(fulldf) )
}
a <- df4 %>% group_by(ID) %>% do(pattern(.) ) ##### data
a <- na.omit ( a [,c('original_row_NO','last_dose','last_doseperkg')] )
df5 <- merge(x = df4, y = a, by = "original_row_NO", all = TRUE)
##---------------------- 4 .formulation -------------------------##
##################### add formulation information #########################
formu_fun <- function (tb) {
tb$formulationNo <- NA # new column for Formulation numbers
iv <- c('H01','H02') # 1
tb$formulation[tb$dosageform %in% iv] <- 'iv'
tb$formulationNo[tb$dosageform %in% iv] <- 1
tablet_mono <- c('C01','C02','C03','C04','C05') # 2
tb$formulation[tb$dosageform %in% tablet_mono] <- 'tablet_mono'
tb$formulationNo[tb$dosageform %in% tablet_mono] <- 2
suppository <- c('B01','B02','B03','B04','B05') # 3
tb$formulation[tb$dosageform %in% suppository] <- 'suppository'
tb$formulationNo[tb$dosageform %in% suppository] <- 3
elixir <- c('A01') # 4
tb$formulation[tb$dosageform %in% elixir] <- 'elixir'
tb$formulationNo[tb$dosageform %in% elixir] <- 4
solution <- c('A02') # 5
tb$formulation[tb$dosageform %in% solution] <- 'solution'
tb$formulationNo[tb$dosageform %in% solution] <- 5
tablet_comb <- c('E01','E05','E06','E10','E12','E14','E18','E19','F05') # 6
tb$formulation[tb$dosageform %in% tablet_comb] <- 'tablet_comb'
tb$formulationNo[tb$dosageform %in% tablet_comb] <- 6
liquid_comb <- c('D01','D03','D06') # 7
tb$formulation[tb$dosageform %in% liquid_comb] <- 'liquid_comb'
tb$formulationNo[tb$dosageform %in% liquid_comb] <- 7
other <- c('A03','A04','F07','G13') # 8
tb$formulation[tb$dosageform %in% other] <- 'other'
tb$formulationNo[tb$dosageform %in% other] <- 7
tb$formulationfactor <- factor(tb$formulationNo,labels=c(
'iv','tablet_mono','suppository',
'elixir','solution','tablet_comb','liquid_comb' ))
return (tb)
}
df6 <- formu_fun(df5)
# test formulation
# outersect <- function(x, y) {
# cat ('only left:')
# print (setdiff(x, y))
# cat ('only right:')
# print ( setdiff(y, x))
# return( sort(c(setdiff(x, y), setdiff(y, x))) )
# }
#
# nrow ( df6[is.na(df6$formulation),])
# nrow ( df6[df6$EVID==0,])
# outersect( df6$original_row_NO[df6$EVID==0],
# df6$original_row_NO[is.na(df6$formulation)] )
#
##########################################################################
##---------------------- 4 .Final NONMEM format -------------------------##
###########################################################################
df_NM <- df6
df_NM$AMT <- round(df_NM$dose*1000/151,digits=1) #dose mg -> molar
df_NM$RATE <- ifelse(df_NM$formulationNo==1,df_NM$AMT/0.25,0 )
df_NM <- rename(df_NM,WT=WEIGHT) # rename weight -> WT
##--------------------- 4. add Compartment -----------------------##
df_NM$CMT[df_NM$formulationNo==1] <- 2
df_NM$CMT[df_NM$EVID==0 ] <- 2
df_NM$MDV <- ifelse(df_NM$EVID==1,1,0)
names(df_NM)
df_NM2 <- select(df_NM,ID,TIME,AMT,RATE,CMT,EVID,DV,MDV,WT,formulationNo,
AGE,original_row_NO,age_group)
############# iv group ####################
# All subjects containing one iv dosing
iv_ID <- df6$ID[df6$formulation=='iv']
iv_ID <- unique( ( na.omit (iv_ID )) )
n_distinct(iv_ID)
unique(iv_ID)
df_iv_ID <- df6[df6$ID %in% iv_ID, ]
## all subjects contianing only iv id
all_iv <- function(tb) { # return all iv group
if (all(tb$formulationNo==1,na.rm = TRUE)) {
return(tb)
} else {return (data.frame())}
}
df_iv_only <- df6 %>% group_by(ID) %>% do(all_iv(.))
n_distinct(df_iv_only$ID)
unique(df_iv_only$ID)
outersect( unique(iv_ID), unique(df_iv_only$ID) )
unique(df_iv_only$ID)
n_distinct(df_iv_only$ID)
df_iv_only
I
df_iv_only
View(df_iv_only)
detach("package:aaasibo", unload=TRUE)
x <- c(-5:5, NA)
if_else(x < 0, NA_integer_, x)
x
if_else(x < 0, "negative", "positive", "missing")
ifelse(x < 0, "negative", "positive", "missing")
ifelse(x < 0, "negative", "positive", "missing")
x <- c(-5:5, NA)
if_else(x < 0, "negative", "positive", "missing")
ifelse(x < 0, "negative", "positive", "missing")
ifelse(x < 0, "negative", "positive")
ifelse(x < 0, "negative", "positive")
ifelse(x < 0, "negative", "positive")
x <- factor(sample(letters[1:5], 10, replace = TRUE))
x
ifelse(x %in% c("a", "b", "c"), x, factor(NA))
if_else(x %in% c("a", "b", "c"), x, factor(NA))
x <- c(-5:5, NA)
if_else(x < 0, "negative", "positive", "missing")
ifelse(x < 0, "negative", "positive")
x <- c(-5:5, NA)
x
if_else(x < 0, "negative", "positive", "missing")
ifelse(x < 0, "negative", "positive")
path <- 'O:\\G_Drive\\code\\R_Script\\0_Projects\\data_cleaning\\Copy of Group A analysis merged data for popPK-pinkedited.xlsx' # original dataset location
setwd(dirname(path))
df_iv_only$LLQQ [!(df_iv_only$ID %in% c(99,98,100,101,104,112)),] <- above_LLOQ
df_iv_only$LLQQ [!(df_iv_only$ID %in% c(99,98,100,101,104,112)),] <- 'above_LLOQ'
unique(df_iv_only$ID)
library("aaasibo", lib.loc="C:/Program Files/R/R/library")
outersect( unique(df_iv_only$ID),c(99,98,100,101,104))
outersect( unique(df_iv_only$ID),c(99,98,100,101,104,112))
df_iv_only
df_iv_only$LLQQ [ df_iv_only$ID %in% c(99,98,100,101,104)] <- 'above_LLOQ'
outersect( unique(df_iv_only$ID),c(99,98,100,101,104,112))
library("aaasibo", lib.loc="C:/Program Files/R/R/library")
detach("package:aaasibo", unload=TRUE)
library(aaasibo)
outersect()
outersect
outersect()
library("aaasibo", lib.loc="C:/Program Files/R/R/library")
outersect()
library("aaasibo", lib.loc="C:/Program Files/R/R/library")
con_para
con_para()
library(aaasibo)
con_para()
x <- "a=10 ,
b=3,
c=1.86E+04,
d=a-b,
e=3+d,
g=c/100 "
con_para(x)
aaa <- con_para(x)
aaa
x <- "a=10 ,
b=3,
c=1.86E+04,
d=a-b,
e=3+d,
g=c/100 "
aaa <- con_para(x)