Hello,

One more thing, if you do cbind(year = rownames(dat), dat), then the year variable defaults to a factor. Maybe it's better if you transform it into numeric:

cbind(year = as.numeric(rownames(dat)), dat)


Rui Barradas

Em 27-08-2013 21:09, catalin roibu escreveu:
Thank you very much!
It's work!


On 27 August 2013 22:44, catalin roibu <catalinro...@gmail.com> wrote:

Hello!
Thank's but don't work.
my data is like this>,and I want rownames to be first column variable
named year.
   Jan        Feb        Mar         Apr        May       Jun
1902 -0.5894558 -0.6744898 -0.2104284  0.28221615  0.9674216 0.5894558
1903 -0.3554904 -1.0853249 -0.9674216  0.67448975  1.2206403 1.9145058
1904 -1.2206403 -0.7647097 -0.5084881 -0.76470967  0.5084881 1.3829941
1905 -0.8616341 -0.2822161 -1.2206403  0.58945580  0.4307273 1.3829941
1906 -0.5084881 -0.5894558 -0.5084881  0.35549042  1.9145058 1.5932188
1907 -0.7647097 -0.8616341 -0.2822161 -0.06968492 -0.2104284 0.5894558
             Jul        Aug         Sep        Oct        Nov        Dec
1902  0.8616341  0.5084881 -0.06968492  0.3554904 -1.5932188  0.2104284
1903  1.0853249  0.4307273 -1.91450583  0.0000000 -0.7647097 -0.2822161
1904 -0.2822161  1.3829941  0.58945580  0.3554904  0.2822161 -0.7647097
1905  0.2104284 -0.2104284 -0.28221615  0.4307273 -0.2822161 -0.2822161
1906  0.9674216  0.5084881  0.43072730 -0.8616341  0.0000000 -0.2104284
1907  1.3829941 -0.7647097  0.43072730 -1.3829941 -0.2822161 -0.2822161


On 27 August 2013 22:41, Rui Barradas <ruipbarra...@sapo.pt> wrote:

Hello,

If your data.frame is named 'dat', try the following.

cbind(year = rownames(dat), dat)

Hope this helps,

Rui Barradas

Em 27-08-2013 20:34, catalin roibu escreveu:

  hello all!
I have a problem! I don't know how to convert row names in first column
variables.

Thank you very much for your help!

CR




--
---
Catalin-Constantin ROIBU
Lecturer PhD, Forestry engineer
Forestry Faculty of Suceava
Str. Universitatii no. 13, Suceava, 720229, Romania
office phone     +4 0230 52 29 78, ext. 531
mobile phone   +4 0745 53 18 01
                        +4 0766 71 76 58
FAX:                +4 0230 52 16 64
silvic.usv.ro





______________________________________________
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.

Reply via email to