[R] paste dimnames problem

Dimitris Rizopoulos dimitris.rizopoulos at med.kuleuven.ac.be
Tue Apr 27 11:50:59 CEST 2004


Dear Arne,

you could use something like:

n <- list(c("NEW", "OLD", "PRG"), c("04h", "24h"), c("000mM", "010mM",
"025mM", "050mM", "100mM"))
dnames <- apply(expand.grid(n), 1, function(x) paste(x, collapse=""))
dnames

I hope this helps.

Best,
Dimitris

----
Dimitris Rizopoulos
Doctoral Student
Biostatistical Centre
School of Public Health
Catholic University of Leuven

Address: Kapucijnenvoer 35, Leuven, Belgium
Tel: +32/16/396887
Fax: +32/16/337015
Web: http://www.med.kuleuven.ac.be/biostat/
     http://www.student.kuleuven.ac.be/~m0390867/dimitris.htm


----- Original Message ----- 
From: <Arne.Muller at aventis.com>
To: <r-help at stat.math.ethz.ch>
Sent: Tuesday, April 27, 2004 11:26 AM
Subject: [R] paste dimnames problem


> Hello,
>
> I've the following list n:
> > n
> [[1]]
> [1] "NEW" "OLD" "PRG"
>
> [[2]]
> [1] "04h" "24h"
>
> [[3]]
> [1] "000mM" "010mM" "025mM" "050mM" "100mM"
>
> where
>
> n <- dimnames(some.multidim.array)
>
> I'm trying to define a generic function that generates meaningful
names from this list, e.g. NEW.04h.000mM would be the first name, then
NEW.04h.010mM, ... . Overall this would generate 30 names (3*2*5).
Here, this would be 3 cascaded loops, but the dimensions of the array
should be flexible.
>
> What would suggest?
>
> I'm happy for your comments,
> +regards,
>
> Arne
>
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://www.stat.math.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide!
http://www.R-project.org/posting-guide.html




More information about the R-help mailing list