The ESS way of doing this is actually M-n and M-p when the point is at the command prompt. You may want to read the ess manual, or at least consult the ess cheat sheet ess.r-project.org