XX<-read.table('children.dat') nn<-nrow(XX) #-------------------------------- # use your student number here as a seed !!!! #-------------------------------- set.seed(1234) #--------------------------------- # take a sample of size n=500 #-------------------------------- n<-500 I<-sample((1:nn),n) X<-XX[I,] # write.table(X,file='ownsample.dat',col.names=FALSE) #--------------------------------------- # consider and name some columns of data matrix #-------------------------------------------------------- m_age<-X[,2] m_height<-X[,3] m_weight<-X[,4] m_smoking<-X[,5] marital_status<-X[,6] social_class<-X[,7] g_age<-X[,10] twins<-X[,12] parity<-X[,14] sex<-X[,15] birth_weight<-X[,16] dead<-X[,17] #--------------------------------------------- # make new variables (column vectors) #------------------------------------------- parity.gt.0<-(parity>0)*1 parity.gt.2<-(parity>2)*1 age.gt.35<-(m_age>35)*1 boy<-(sex==1)*1 smoking<-(m_smoking>0)*1 PT<-(g_age<37)*1 LBW<-(birth_weight<250)*1