Advertisement
karstenw

tuesday-boy

Jan 23rd, 2022
1,586
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
R 0.58 KB | None | 0 0
  1. # http://news.bbc.co.uk/2/hi/programmes/more_or_less/8735812.stm
  2. one_child <- expand.grid(
  3.     sex=c("Boy", "Girl"), wday=c("Mo", "Tue", "We", "Th", "Fr", "Sa", "Su")
  4. ) |>
  5. transform(sex_wday=paste(sex, "-", wday)) |>
  6. subset(select="sex_wday") |>
  7. unlist() |>
  8. unname()
  9.  
  10. two_children <- expand.grid(first=one_child, second=one_child, stringsAsFactors=FALSE) |>
  11. transform(
  12.     tuesday_boy=grepl("Boy - Tue", first) | grepl("Boy - Tue", second),
  13.     two_boys=grepl("Boy", first) & grepl("Boy", second)
  14. )
  15.  
  16. sum(two_children$tuesday_boy & two_children$two_boys) /
  17. sum(two_children$tuesday_boy)
  18.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement