We investigate the qualitative evolution of (D+1)-dimensional cosmological models in f(R) gravity for the general case of the function f(R). The analysis is specified for various examples, including the (D+1)-dimensional generalization of the Starobinsky model, models with polynomial and exponential functions. The cosmological dynamics are compared in the Einstein and Jordan representations of the corresponding scalar-tensor theory. The features of the cosmological evolution are discussed for Einstein frame potentials taking negative values in certain regions of the field space.