Skip to content

Commit

Permalink
instem data used for analysis
Browse files Browse the repository at this point in the history
  • Loading branch information
Yousuf28 committed Sep 16, 2024
1 parent 89d840f commit 8166608
Showing 1 changed file with 15 additions and 10 deletions.
25 changes: 15 additions & 10 deletions BW_R_code/01_intro_bw.R
Original file line number Diff line number Diff line change
Expand Up @@ -17,24 +17,23 @@ library(haven)

# read xpt file with haven package

bw <- haven::read_xpt("~/OneDrive - FDA/yousuf/10_DATA/Biocelerate_shared_data/data/biocelerate_all_data/1MDogA_send/bw.xpt")
## bw <- haven::read_xpt("data/mock_SEND_data/instem/bw.xpt")
bw <- haven::read_xpt("data/mock_SEND_data/instem/bw.xpt")
# write to csv file
# read back the file in dataframe
# attribute (label) lost
# mention to read excel file

# convert to base R dataframe
bw <- as.data.frame(bw)
edit(bw)
## edit(bw)
# getting a peek at data
head(bw)

# View the whole table
View(bw)
# edit()
# know more about your dataframe/table
str(bw)
## str(bw)

print(head(bw$BWSTRESN))
head(bw$BWSTRESN)
Expand All @@ -60,9 +59,10 @@ unq_animals <- unique(bw$USUBJID)
unq_animals
length(unq_animals)

# table for a animal

an_animal <- bw[bw$USUBJID=='43066-1101',]
# table for a animal, pick first one
one_animal <- bw$USUBJID[1]
one_animal
an_animal <- bw[bw$USUBJID==one_animal,]
View(an_animal)


Expand Down Expand Up @@ -129,9 +129,7 @@ barplot(table(bw$BWTESTCD))
## ggplot2::ggplot(data=bw, ggplot2::aes(VISITDY,BWSTRESN, color=VISITDY))+
## ggplot2::geom_point()

dm <- haven::read_xpt("~/OneDrive - FDA/yousuf/10_DATA/Biocelerate_shared_data/data/biocelerate_all_data/1MDogA_send/dm.xpt")
## dm <- haven::read_xpt("data/mock_SEND_data/instem/dm.xpt")
## dm <- haven::read_xpt('../../data/PDS/dm.xpt')
dm <- haven::read_xpt("data/mock_SEND_data/instem/dm.xpt")
dm <- as.data.frame(dm)
head(dm)
bw_m <- bw[, c('STUDYID','DOMAIN','USUBJID','BWTESTCD',
Expand All @@ -145,6 +143,13 @@ head(df_merge)
#

unique(df_merge$SETCD)

plot(df_merge$BWSTRESN,
col = ifelse(df_merge$SEX=='M','skyblue','red'),
## xlab = 'VISITDAY',
ylab = 'Body Weight',
pch=19,cex = .8)
legend('bottomright',c('Male','Female'),col = c('skyblue','red'),pch=19)
# plot BWSTRESN and VISITDY
plot(df_merge$VISITDY,df_merge$BWSTRESN,
col = ifelse(df_merge$SEX=='M','skyblue','red'),
Expand Down

0 comments on commit 8166608

Please sign in to comment.