I am trying to write code to create a string to be executed as a command. The
string will be of the form:
"param <- param[,rev(seq_len(dataYLen)),,drop = FALSE]"
Now just creating that string is simple enough. Where the problem arises is
the array param could be 2, 3, or 4 dimensions, and the dimension where
"rev(seq_len(dataYLen))" occurs can vary. At present I have the following
paramLen <- 3
latLoc <- 2
myComma1 <- paste(rep(',', times = (latLoc-1)), 'rev(seq_len(dataYLen))',
myComma2 <- paste(rep(',', times = (paramLen-latLoc+1)),sep="",
paramCommand <- paste0('param <- param[', myComma1, myComma2, 'drop =
(paramLen can be 2,3,4 and latLoc can be 1,2,3,4) but this strikes me as
pretty kludgy. I am hoping there is a more elegant way of doing this.
"The contents of this message do not reflect any position of the U.S.
Government or NOAA."
Supervisory Operations Research Analyst
Environmental Research Division
Southwest Fisheries Science Center
***Note new address and phone***
110 Shaffer Road
Santa Cruz, CA 95060
Fax: (831) 420-3980
e-mail: roy.mendelss...@noaa.gov www: http://www.pfeg.noaa.gov/
"Old age and treachery will overcome youth and skill."
"From those who have been given much, much will be expected"
"the arc of the moral universe is long, but it bends toward justice" -MLK Jr.
Rfirstname.lastname@example.org mailing list -- To UNSUBSCRIBE and more, see
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.