0

Use the Aids2 dataset(see below). Use a sample size of 50 for each of the following.

Show the sample drawn using simple random sampling with replacement. Show the frequencies (the absolute counts) of female and male patients (sex) and status at end of observation (status) in the sample.

packages prob and sampling may be used

My codes here:

aids <- read.csv(file="D:/Aids2.csv", header=T)
library(sampling)

nrow(aids)
s <- srswor(50, 2843)
rows <- (1:nrow(aids))[s!=0]
rows <- rep(rows, s[s!=0])

female <-rows[aids$sex=="F"]
male <- rows[aids$sex=="M"]

table(female)
table(male)

dead<-rows[aids$status=="D"]
alive<-rows[aids$status=="A"]

table(dead)
table(alive)

So its like I know everything runs fine, but Im not sure how to achieve exactly what the question asking. Can anyone help me to fix my script

links of the file: https://drive.google.com/file/d/1vVKYQ_oDu6Fv00P-vgypifxfMgnyV7qw/view?usp=sharing

1 Answers1

1

I don't have access to the data but something like this should work.

aids <- read.csv(file="D:/Aids2.csv", header=T)
#Select 50 random rows with replacement
sample_data <- sample_data[sample(nrow(sample_data), 50, replace = TRUE), ]
#Count sex in sample_data
table(sample_data$sex)
#Count status
table(sample_data$status)
Ronak Shah
  • 377,200
  • 20
  • 156
  • 213