Closed zhengxwen closed 9 years ago
This function is available now (gdsfmt_1.1.3), see the document of apply.gdsn
:
library(gdsfmt)
# cteate a GDS file
f <- createfn.gds("test.gds")
(n1 <- add.gdsn(f, "matrix", val=matrix(1:(10*6), nrow=10)))
(n2 <- add.gdsn(f, "string", val=matrix(paste("L", 1:(10*6), sep=","), nrow=10)))
read.gdsn(index.gdsn(f, "string"))
n1.1 <- add.gdsn(f, "transpose.matrix", storage="int", valdim=c(6,0))
n2.1 <- add.gdsn(f, "transpose.string", storage="string", valdim=c(6,0))
# Apply functions over rows of matrix
apply.gdsn(n1, margin=1, FUN=`c`, as.is="gdsnode", target.node=n1.1)
# matrix transpose
read.gdsn(n1)
read.gdsn(n1.1)
# Apply functions over rows of matrix
apply.gdsn(n2, margin=1, FUN=`c`, as.is="gdsnode", target.node=n2.1)
# matrix transpose
read.gdsn(n2)
read.gdsn(n2.1)
# close
closefn.gds(f)
# cteate a GDS file
f <- createfn.gds("test.gds")
(n1 <- add.gdsn(f, "matrix", val=matrix(1:(10*6), nrow=10)))
n1.1 <- add.gdsn(f, "transpose.matrix", storage="int", valdim=c(6,0))
n1.2 <- add.gdsn(f, "n.matrix", storage="int", valdim=c(0))
# Apply functions over rows of matrix
apply.gdsn(n1, margin=1, FUN=function(x) list(x, x[1]),
as.is="gdsnode", target.node=list(n1.1, n1.2))
# matrix transpose
read.gdsn(n1)
read.gdsn(n1.1)
read.gdsn(n1.2)
# close
closefn.gds(f)
The value returned from the user-defined function can be automatically appended to a specified variable?