Solving the birthday problem in R with one line of code

If you want to quickly calculate the probability of 2 or more people who have the same birthdays in a group. This can be done easily with the pbirthday function from the Stats package.

#Just install stats package
install.packages("stats")

#Load library
library(stats)

#Use pbirthday function
#n = number of people in your group
#classes = 365 (days in the year)
#coincident = the number of people who have the same birthday

pbirthday(n = 25, classes = 365, coincident = 2)
pbirthday function results.png

The probability of 2 people in a group of 25, having the same birthday is 0.5686997 or 57%. Astounding odds!