I have a data frame containing \"name\" of U.S. Presidents, the years when they start and end in office, (\"from\" and \"to\" columns
\"name\"
\"from\"
\"to\"
Here is a quick base-R solution, where Df is your data.frame:
R
Df
data.frame
do.call(rbind, apply(Df, 1, function(x) { data.frame(name=x[1], year=seq(x[2], x[3]))}))
It gives some warnings about row names, but appears to return the correct data.frame.