[R] Setting rownames (was Please help.... i know its trivial)
Prof Brian Ripley
ripley at stats.ox.ac.uk
Tue Apr 17 08:47:11 CEST 2007
On Tue, 17 Apr 2007, Petr Klasterecky wrote:
> Patrick Callier napsal(a):
>> rownames is the command you want, I think.
>>
>> rownames(A) <- seq(1:8)
>>
>
> Yes. More generally
> rownames(A) <- 1:length(A[,1])
Better
rownames(A) <- seq_len(nrow(A))
which works correctly if the length is 0 or there are zero columns, and is
self-explanatory.
Whenever you use 1:n you need to consider what you want if n <= 0.
> And keep in mind that nobody is going to help you next time, if you
> won't give a clear and informative SUBJECT in your message. Here it
> should have been something like 'wrong row names in subset' or
> 'dataframe subset question' etc, certainly not 'please help me, it's
> trivial'...
>
> Btw, there is something like the posting guide for this list (see footer).
And please change the subject line to something appropriate when replying.
>
> Petr
>
>
--
Brian D. Ripley, ripley at stats.ox.ac.uk
Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/
University of Oxford, Tel: +44 1865 272861 (self)
1 South Parks Road, +44 1865 272866 (PA)
Oxford OX1 3TG, UK Fax: +44 1865 272595
More information about the R-help
mailing list