SML R Code