From cberry at tajo.ucsd.edu  Fri Nov 26 08:19:44 2010
From: cberry at tajo.ucsd.edu (Charles C. Berry)
Date: Thu, 25 Nov 2010 23:19:44 -0800
Subject: [Rd] Request:  kronecker to get a sep= argument
In-Reply-To: <Pine.LNX.4.64.1011252305130.17459@tajo.ucsd.edu>
References: <4CEEC2B0.5060203@yorku.ca>
	<Pine.LNX.4.64.1011252305130.17459@tajo.ucsd.edu>
Message-ID: <Pine.LNX.4.64.1011252318340.17459@tajo.ucsd.edu>

On Thu, 25 Nov 2010, Charles C. Berry wrote:

> On Thu, 25 Nov 2010, Michael Friendly wrote:
>
>>  kronecker, with make.dimnames=TRUE uses a hardwired sep=":" in the line
>>
>>             tmp <- outer(dnx[[i]], dny[[i]], FUN = "paste", sep = ":")
>>
>>  For an application in which dimnames arise from an n-way array, where
>>  different dimensions have
>>  different roles, and I would like to be able to use kronecker in the form
>>
>>  kronecker(A, B, make.dimnames=TRUE, sep='/')
>>
>>  All this requires is to change the following two lines:
>>
>>  kronecker <- function (X, Y, FUN = "*", make.dimnames = FALSE, sep=":"
>>  ...)
>>  {
>>   ...
>>             tmp <- outer(dnx[[i]], dny[[i]], FUN = "paste", sep = sep)
>> }
>> 
>>
>>  Otherwise, I have to reproduce the logic inside kronecker() in my
>>  application function.
>
> Or add one line of code:
>
> res <- kronecker(m1,m3,make.dimnames=T)
> dimnames(res) <-
> 	 lapply( dimnames(res), sub, pattern=":", replacement="/" )
>
> HTH,
>
> Chuck
>
> p.s. your suggestion could break code that others may have written like
>
> 	kronecker( letters[1:3], diag(LETTERS[1:2]), paste, sep='*' )

make that

 	kronecker( letters[1:3], diag(LETTERS[1:2]), paste )


>
>
>>
>>  -Michael
>>
>>  --
>>  Michael Friendly     Email: friendly AT yorku DOT ca
>>  Professor, Psychology Dept.
>>  York University      Voice: 416 736-5115 x66249 Fax: 416 736-5814
>>  4700 Keele Street    Web:   http://www.datavis.ca
>>  Toronto, ONT  M3J 1P3 CANADA
>>
>>  ______________________________________________
>>  R-devel at r-project.org mailing list
>>  https://stat.ethz.ch/mailman/listinfo/r-devel
>> 
>> 
>
> Charles C. Berry                            Dept of Family/Preventive 
> Medicine
> cberry at tajo.ucsd.edu			    UC San Diego
> http://famprevmed.ucsd.edu/faculty/cberry/  La Jolla, San Diego 92093-0901
>
> ______________________________________________
> R-devel at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
>
>

Charles C. Berry                            Dept of Family/Preventive Medicine
cberry at tajo.ucsd.edu			    UC San Diego
http://famprevmed.ucsd.edu/faculty/cberry/  La Jolla, San Diego 92093-0901



[Rd] Request: kronecker to get a sep= argument
Charles C. Berry