4. Mrs. Smith is participating in a clinical trial. She started treatment on Mar
ID: 2949084 • Letter: 4
Question
4. Mrs. Smith is participating in a clinical trial. She started treatment on March 3, 1999 and is expected to have a folow-up visit every 6-months for the next three years. (a) Create a vector of the dates when Mrs. Smith is expected to show up for her follow- up visit . (b) Mrs. Smith showed up on the following dates, enter these dates into R as Date objects 9/10/1999, 2/10/2000, 9/16/2000, 2/23/2001, 99/2001 3/28/2002 ) It is unrealistic to expect Mrs. Smith to show up on the dates from part (a). However, did Mrs. Smith have a folow-up appointment within three weeks of each expected follow-up date?Explanation / Answer
The detailed r code for all the parts is as follows :
# dates for schedule appointements
shd.dates<- seq(as.Date("1999/9/3"), by = "6 months", length.out = 6)
shd.dates<- as.Date(shd.dates,"%m/%d/%Y")
# dates of arrival as given in the question
arr.dates<- (c("9/10/1999", "2/10/2000", "9/16/2000", "2/23/2001","9/9/2001","3/28/2002"))
arr.dates<- as.Date(arr.dates,"%m/%d/%Y")
# combine to form a data frame
df<- cbind.data.frame(shd.dates,arr.dates)
# difference in week of the 2 dates, 3 instances where the follow up happened within 3 weeks
diff_in_weeks = difftime(arr.dates,shd.dates, units = "weeks")
diff_in_weeks
Hope this helps
We first entered the dates and then using the seq function created a vector of scheduled appointments , then calculated the difference between the scheduled and the arrival date in weeks to answer part 3 . If the difference is less than 3 then the appointment happened within 3 weeks else not .
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.