Skip to content
Permalink
main
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
library(dplyr)
## 10% sample
data1<-read.csv("C:\\Users\\tysia\\Desktop\\ADPA + SEX.csv")###Add file name to be read
data1$index <- 1:nrow(data1)###add on index
newdata <- data1[ which(data1$AVISITN == 6
& data1$PARAMCD == "PASI"), ]
set.seed(1234)
samp_10<-sample(1:nrow(newdata), 183)
x<-newdata[samp_10,]
data1$AVAL[x$index]<-NA
write.csv(data1,"C:\\Users\\tysia\\Desktop\\MCAR10%.csv", row.names = FALSE)
##20% Sample
data2<-read.csv("C:\\Users\\tysia\\Desktop\\ADPA + SEX.csv")###Add file name to be read
data2$index <- 1:nrow(data2)###add an index
set.seed(1234)
samp_20<-sample(1:nrow(newdata), 366)
x<-newdata[samp_20,]
data2$AVAL[x$index]<-NA
write.csv(data2,"C:\\Users\\tysia\\Desktop\\MCAR20%.csv", row.names = FALSE)
## 30% sample
data3<-read.csv("C:\\Users\\tysia\\Desktop\\ADPA + SEX.csv")###Add file name to be read
data3$index <- 1:nrow(data3)###add an index
set.seed(1234)
samp_30<-sample(1:nrow(newdata), 549)
x<-newdata[samp_30,]
data3$AVAL[x$index]<-NA
write.csv(data3,"C:\\Users\\tysia\\Desktop\\MCAR30%.csv", row.names = FALSE)