Roslina Zakaria <zroslina <at> yahoo.com> writes: > How to swap and rearrange the row so that I will have > Jan-Dec in order? > > est31 > p0 est.alpha est.beta est.rate > Jan 0.8802867 0.7321440 7.241757 0.1380880 > Mar 0.8598566 0.7096567 7.376367 0.1355681 > May 0.6204301 0.8657272 6.036106 0.1656697 > July 0.5032258 0.9928488 4.027408 0.2482986 > Aug 0.5322581 0.9625738 4.103121 0.2437169 > Oct 0.6792115 0.8526226 5.105218 0.1958780 > Dec 0.8397849 0.7490287 7.070349 0.1414357 > > est30 > p0 est.alpha est.beta est.rate > Apr 0.7296296 0.7929348 6.303877 0.1586325 > Jun 0.5574074 0.8588608 5.695905 0.1755647 > Sept 0.6066667 0.9031150 4.594891 0.2176330 > Nov 0.7725926 0.7600906 5.636366 0.1774193
# Generate sample data est31 = data.frame(p0=1:3,x=2:4) rownames(est31) = c("Jan","Mar","Apr") est30 = data.frame(p0=5:7,x=3:5) rownames(est30) = c("Feb","Jun","May") # ------------------------- est = rbind(est31,est30) est goodsort = c("Jan","Feb","Apr","May","Jun") est.sorted = est[goodsort,] est.sorted ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.