From: Robin Hankin <r.hankin_at_noc.soton.ac.uk>

Date: Thu 27 Jul 2006 - 23:54:02 EST

Date: Thu 27 Jul 2006 - 23:54:02 EST

Hi

Commented, minimal, self-contained, reproducible toy example follows.

f <- function(a){cbind(a,a+1,rev(a))} #real function a ghastly nightmare

a

*[1,] 1 2 5
**[2,] 2 3 4
*

[3,] 3 4 3

*[4,] 4 5 2
**[5,] 5 6 1
*

# f() works as desired.

# Now introduce A2, that includes zeroes. In my application, f(A2)
would fail

because of the zeroes.

A2 <- c(1,0,0,2,4,0,3)

I can strip the zeroes out and call f(): f(A2[A2>0])

a

*[1,] 1 2 3
**[2,] 2 3 4
*

[3,] 4 5 2

[4,] 3 4 1

which is fine. How to put the zeroes back in in the appropriate rows and get the following:

> cbind(c(1,0,0,2,4,0,3),c(2,0,0,3,5,0,4),c(3,0,0,4,2,0,1))

[,1] [,2] [,3]

[1,] 1 2 3

*[2,] 0 0 0
**[3,] 0 0 0
**[4,] 2 3 4
**[5,] 4 5 2
**[6,] 0 0 0
**[7,] 3 4 1
*

>

anyone?

-- Robin Hankin Uncertainty Analyst National Oceanography Centre, Southampton European Way, Southampton SO14 3ZH, UK tel 023-8059-7743 ______________________________________________ R-help@stat.math.ethz.ch 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 Fri Jul 28 01:10:35 2006

Archive maintained by Robert King, hosted by
the discipline of
statistics at the
University of Newcastle,
Australia.

Archive generated by hypermail 2.1.8, at Fri 28 Jul 2006 - 04:18:26 EST.

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