Dirks was born in Bangkok, Thailand, in 1978. His mother Suree, a Thai Chinese woman who worked in a bank at the time, his father, Michael Dirks, was a mathematics teacher at the International School Bangkok recruited from the United States. After about a year, the family, including older brother William, moved back to Vancouver, British Columbia, Canada so that his father could pursue doctoral studies in mathematics education at the University of British Columbia. Four years later the family settled in Michael's hometown of Spokane, Washington, where he took a job teaching math at North Central High School and Spokane Falls Community College.
Robert attended Lewis and Clark High School, where he excelled academically, entering and winning many math competitions. He was selected to do cardiovascular research at the University of Washington over the summer before his senior year. During that year, he received the top score of 5 on every Advanced Placement exam he took, and was chosen as class valedictorian in 1996. Shortly after graduation Robert and three of his classmates were one of three high school winners of the ExploraVision national scientific contest, earning them and their families a trip to Washington, D.C. The topic of their project was the future of nanotechnology.
Although he had been accepted to the Massachusetts Institute of Technology, he chose instead to attend Wabash College in Crawfordsville, Indiana.  He graduated summa cum laude and with Phi Beta Kappa honors, from Wabash in 2000 with a double major in chemistry and math.  He also did a two minors in biology and music, playing the bassoon, clarinet and piano.
He then began graduate studies in chemistry at the California Institute of Technology in Pasadena, California. He received his Ph.D. in 2005 and remained at Caltech for a postdoctoral fellowship. During his years there he met Christine Ueda, another doctoral student who became his wife.