[Distr-commits] r944 - branches/distr-2.6/pkg/distrTeach/R
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Mon Jul 28 12:47:09 CEST 2014
Author: ruckdeschel
Date: 2014-07-28 12:47:09 +0200 (Mon, 28 Jul 2014)
New Revision: 944
Modified:
branches/distr-2.6/pkg/distrTeach/R/illustLLN.R
Log:
[distrTeach] removed ::: internal dependencies (within distr-Fam of pkgs) by copying respective routines
Modified: branches/distr-2.6/pkg/distrTeach/R/illustLLN.R
===================================================================
--- branches/distr-2.6/pkg/distrTeach/R/illustLLN.R 2014-07-24 16:24:26 UTC (rev 943)
+++ branches/distr-2.6/pkg/distrTeach/R/illustLLN.R 2014-07-28 10:47:09 UTC (rev 944)
@@ -90,7 +90,7 @@
.mpresubs <- function(inx)
- distr:::.presubs(inx, c("%C", "%D", "%N", "%P", "%Q", "%A",
+ .presubs(inx, c("%C", "%D", "%N", "%P", "%Q", "%A",
"%X"),
list(as.character(class(Distr)[1]),
as.character(date()),
@@ -169,4 +169,37 @@
}
+#------------------------------------
+#### utility copied from package distr v.2.6 svn-rev 943
+#------------------------------------
+.presubs <- function(inp, frompat, topat){
+### replaces in an expression or a string all frompat patterns to topat patterns
+logic <- FALSE
+inCx <- sapply(inp,
+ function(inpx){
+ inC <- deparse(inpx)
+ l <- length(frompat)
+ for(i in 1:l)
+ { if (is.language(topat[[i]])){
+ totxt <- deparse(topat[[i]])
+ totxt <- gsub("expression\\(", "\", ", gsub("\\)$",", \"",totxt))
+ if (length(grep(frompat[i],inC))) logic <<- TRUE
+ inC <- gsub(frompat[i],totxt,inC)
+ }else inC <- gsub(frompat[i], topat[[i]], inC)
+ }
+ return(inC)
+ })
+if(length(grep("expression",inCx))>0)
+ inCx <- gsub("expression\\(", "", gsub("\\)$","",inCx))
+if (length(inCx) > 1) {
+ inCx <- paste(inCx, c(rep(",", length(inCx)-1), ""),
+ sep = "", collapse = "\"\\n\",")
+ if ( any(as.logical(c(lapply(inp,is.language)))) | logic )
+ inCx <- paste("expression(paste(", gsub("\\\\n"," ", inCx), "))", sep ="")
+ else
+ inCx <- paste("paste(",inCx,")", sep ="")
+}else inCx <- paste("expression(paste(",inCx,"))",sep="")
+outC <- eval(parse(text = eval(inCx)))
+return(outC)
+}
More information about the Distr-commits
mailing list