Re: [R] I want my row name to be a variable

From: stephen sefick <ssefick_at_gmail.com>
Date: Sat, 15 Nov 2008 21:21:20 -0500

#if this doesn't work then swap the rownames... = ... to ...=rownames... a <- data.frame(your.df, rownames(your.df)=Var3)

On Sat, Nov 15, 2008 at 5:34 PM, CE.KA <ce.kaya75_at_yahoo.fr> wrote:
>
> Hi R users
>
> Imagine this data.frame:
>>X
>
> Var1 Var2
> A 22 13
> B 5 2
> C 12 8
> D 1 99
>
> A,B,C,D are the rows names (or index)
>
> Is there a way to create a new variable in this data frame
> which name is Var3 and which contains the rows names:
>
> Var1 Var2 Var3
> A 22 13 A
> B 5 2 B
> C 12 8 C
> D 1 99 D
>
> I tried as.data.frame(array(x, dim(x), dimnames(x)))
> but it doesn'work
>
> Sincerely yours
>
> --
> View this message in context: http://www.nabble.com/I-want-my-row-name-to-be-a-variable-tp20520180p20520180.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> R-help_at_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.
>

-- 
Stephen Sefick
Research Scientist
Southeastern Natural Sciences Academy

Let's not spend our time and resources thinking about things that are
so little or so large that all they really do for us is puff us up and
make us feel like gods.  We are mammals, and have not exhausted the
annoying little problems of being mammals.

								-K. Mullis

______________________________________________
R-help_at_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.
Received on Sun 16 Nov 2008 - 02:37:28 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Sun 16 Nov 2008 - 03:30:25 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive