(See also RegExp.)
Modify all lines that have a third column starting with 'Y' to 'R', where columns are defined by tabs, and do the replacement at most once per line.
1,$s/\(^[^ ]* [^ ]* \)'Y'/\1'R'/
Match all locations in a number where a comma should be placed.
(?<=\\d)(?=(\\d\\d\\d)+$)
$num =~ s/(?<=\\d)(?=(\\d\\d\\d)+$)/,/g;