I can't recall R2-D2 ever meeting Yoda in the prequel movies, and I haven't read many novels set in the prequel-era. Therefore I cannot be certain R2 has ever actually seen Yoda.
That said, I'm going to continue my answer with the assumption that R2 HAS seen Yoda, but I have no evidence for this. Occam's Razor would suggest the answer is, "R2 never saw Yoda"...but that wouldn't be as fun.
R2, when he met Yoda again on Dagobah, was somewhat irate. Yoda had blinded Luke's instruments, causing them to crash into the swamp. Yoda put R2 through the whole 'travel through the water and get eaten' thing...not R2's happiest moment.
That said, R2 knew it was for Luke's benefit - Yoda was trying to teach. If R2 didn't act as if he wasn't aware of who Yoda was, it could have lead to some uncomfortable questions and/or undermined Yoda's efforts.
So, they played for a bit - R2 gave gentle rebukes (Yoda held Dooku's force lightning in his palm, the arc welder was gentle by that standard) and Yoda played the silly little native for a bit. Inside, they were both grinning.