n = 10000 #Number of flips coin <- sample(c("Heads", "Tails"), n, rep = T) #The coin flip MondayHeads <- 0 MondayTails <- 0 TuesdayTails <- 0 #Loop to count the outcome for (i in coin) { if (i == "Tails") MondayTails <- MondayTails+ 1} for (i in coin) { if (i == "Tails") TuesdayTails <- TuesdayTails + 1} for (i in coin) { if (i == "Heads") MondayHeads <- MondayHeads + 1} Tails <- sum(coin == "Tails") Tails #Number of tails Heads <- sum(coin == "Heads") Heads #Number of Heads MondayHeads #Number of Monday and Heads MondayTails #Number of Monday and Tails TuesdayTails #Number of Tuesday and Tails
Get involved in philosophical discussions about knowledge, truth, language, consciousness, science, politics, religion, logic and mathematics, art, history, and lots more. No ads, no clutter, and very little agreement — just fascinating conversations.