[R] Ordering of rows/names

ripley@stats.ox.ac.uk ripley at stats.ox.ac.uk
Mon Nov 18 22:27:56 CET 2002


Impossible to say without knowing what is inside your function.
But why are you getting the row names from the first column of e3 and not
from its row names?

The following construction is often useful.

new <- old

new[] <- someFunction(old)

which changes the entries but preserves the attributes (including names
and row names).  In your case it might be new[-1].

On Mon, 18 Nov 2002, Paul Boutros wrote:

> I have a data.frame e3.  I use a function on it:
> n3 <- normalize.qspline(x = e3, samples = 0.07, na.rm = TRUE);
>
> The resulting data.frame has lost it's row-names and column names.  This
> is the natural behaviour of the function I am calling, and I can't alter
> that at the moment.  However, the data *is* in the correct order, as it
> was initially -- the names are just missing in the new data structure.
>
> If I just use:
> q3 <- data.frame(n3, row.names=e3[,1]);
> names(q3) <- names(e3)[2:length(names(e3))];
>
> Am I guaranteed to be assigning the row & column names in the correct
> order?  In all the test-cases I have done, they DO appear in the correct
> order, but I wanted to verify that this behaviour is indeed a true
> R-feature as opposed to a nice thing just occurring on my platform.

-- 
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 272860 (secr)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list